-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TypeError: Invalid non-string/buffer chunk] occure when http request will be made after NodeVM run #22
Comments
having similar issues here, minimal code to reproduce: const vm = new (require('vm2').NodeVM);
vm.run('1+1');
process.stdin.pipe(process.stdout); but this does not happen when: const vm = new (require('vm2').NodeVM);
//vm.run('1+1');
process.stdin.pipe(process.stdout); using VM instead of NodeVM seems to be save as well: const vm = new (require('vm2').VM);
vm.run('1+1');
process.stdin.pipe(process.stdout); So I do assume something in the NodeVM.run code seems to be responsible for this. |
Partially fixed in 2.0. Buffer class is no longer globally available by default in NodeVM. More info in readme. The problem is that internal buffers are no longer |
Thank you. But when I set require: true this bug still triggers. This does not happen when I use the tribex-fork. Minimal script to reproduce: const vm = new (require('vm2').NodeVM)({
require: true,
});
vm.run('1+1');
process.stdin.pipe(process.stdout); So I'd suggest re-opening this issue. |
By default, all native modules are whitelisted. Use this: const vm = new (require('vm2').NodeVM)({
require: true,
requireNative: []
});
vm.run('1+1');
process.stdin.pipe(process.stdout); |
@patriksimek Buffers are no longer |
@minecrawler You're absolutely right, but that's not what we're facing here. The problem is that buffers from the same context are not |
The Buffer itself is used globally: lib/buffer.js: const binding = process.binding('buffer');
const bindingObj = {};
binding.setupBufferJS(Buffer.prototype, bindingObj); src/node_buffer.cc: void SetupBufferJS(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
CHECK(args[0]->IsObject());
Local<Object> proto = args[0].As<Object>();
env->set_buffer_prototype_object(proto);
|
The hotfix not to use Buffer renders this module almost useless for me because what I'd like to do does have an internal dependency on buffer. As I don't understand the root of the problem yet, its a bit hard for me to help. So @patriksimek could you please explain what you think is going wrong? |
In short, loading a buffer in VM breaks buffer outside VM. It's an internal problem of Nodejs so I'm not able to fix that atm. I will ask Node devs if there are any plans about fixing this. |
Fixed in 3.0. |
Hi,
when I do a HTTP Request after a run of the NodeVM the following Error appears.
Here is my code:
My node version is 4.3.0
When I remove the 'vm.run' and the 'vm.call' the request works.
I already look into the code but i cant find the reason why this happens but i cant find any reason why :(
The text was updated successfully, but these errors were encountered: