Hi,
when I do a HTTP Request after a run of the NodeVM the following Error appears.
TypeError: Invalid non-string/buffer chunk
at chunkInvalid (_stream_readable.js:372:10)
at readableAddChunk (_stream_readable.js:124:12)
at Socket.Readable.push (_stream_readable.js:110:10)
at TCP.onread (net.js:523:20)
Here is my code:
var NodeVM = require('vm2').NodeVM;
var request = require('request');
var options = {
console: 'inherit',
require: true,
requireExternal: true,
requireNative: [],
requireRoot : "./"
};
var vm = new NodeVM(options);
var functionInSandbox = vm.run("module.exports = function(){ console.log('Output from function in sandbox'); }", __filename);
vm.call(functionInSandbox);
request('http://google.com', function (err, response, body) {
if (err) {
console.error(err.stack);
return;
}
console.log(body);
});
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 :(