Hi,
I'm trying to figure out why builtin modules are proxied from the host and not being required in the vm.
this is my setup currently:
const vm = new NodeVM({
require: {
external: true,
context: 'sandbox',
builtin: ['*'],
},
});
vm.run(...);
inside the VM I require an external module (axios if that matters) and in the chain of dependencies it requires another module (follow-redirects) that does this (more or less):
var Writable = require('stream').Writable;
function RedirectableRequest(options, responseCallback) {
// .....
}
RedirectableRequest.prototype = Object.create(Writable.prototype);
RedirectableRequest.prototype._performRequest = function () { // <-------- this line breaks
// ..........
}
running this code inside the vm throws: TypeError: 'set' on proxy: trap returned falsish for property '_performRequest'.
The stream object is being proxied to the vm.
running this code when stream is being actually required inside the vm (by removing the if statement here: https://github.com/patriksimek/vm2/blob/master/lib/sandbox.js#L133) is working.
running node 6.10.3 on osx.
Thanks
Hi,
I'm trying to figure out why builtin modules are proxied from the host and not being required in the vm.
this is my setup currently:
inside the VM I require an external module (
axiosif that matters) and in the chain of dependencies it requires another module (follow-redirects) that does this (more or less):running this code inside the vm throws: TypeError: 'set' on proxy: trap returned falsish for property '_performRequest'.
The stream object is being proxied to the vm.
running this code when
streamis being actually required inside the vm (by removing the if statement here: https://github.com/patriksimek/vm2/blob/master/lib/sandbox.js#L133) is working.running node 6.10.3 on osx.
Thanks