Closed dimikot closed 9 years ago
I suppose the same happens when I use stdin in the script, and after that I call sandbox ASYNCHRONOUSLY (even on setTimeout). The following script produces exactly the same EPIPE error:
var Sandbox = require('./sandbox/lib/sandbox');
var s = new Sandbox();
var stdin = process.openStdin();
stdin.on('end', function() { console.log("end"); });
setTimeout(function() {
s.run('1+1', function(output) { console.log(output); })
}, 1000);
what does node -e 'process.versions'
print out.
On Tue, Jan 24, 2012 at 9:14 AM, Dmitry Koterov reply@reply.github.com wrote:
The following script (run_stdin.js):
var Sandbox = require('./sandbox/lib/sandbox'); var s = new Sandbox(); var code = ''; var stdin = process.stdin; stdin.resume(); stdin.setEncoding('utf8'); stdin.on('data', function(data) { code += data }); stdin.on('end', function() { s.run(code, function(output) { console.log(output); }); }); ```javascript The following error when I run it:
echo "1+1" | node run_stdin.js
node.js:201 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: write EPIPE at errnoException (net.js:642:11) at Object.afterWrite as oncomplete
If I replace stdin reading with direct ```javascript s.run("1+1", function(output) { console.log(output); });
everything works fine.
How to deal with this?..
Reply to this email directly or view it on GitHub: https://github.com/gf3/sandbox/issues/15
# node -e "console.log(process.versions)"
{ node: '0.6.8',
v8: '3.6.6.19',
ares: '1.7.5-DEV',
uv: '0.6',
openssl: '0.9.8e-fips-rhel5' }
Tested and verified as a bug on the latest node (0.7.1
).
Looks like it's fixed in 0.7.12.
Seems 0.10 does not work still:
root@.../sandbox-master/example# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 7 (wheezy)"
NAME="Debian GNU/Linux"
VERSION_ID="7"
VERSION="7 (wheezy)"
...
root@...sandbox-master/example# nodejs -e "console.log(process.versions)"
{ http_parser: '1.0',
node: '0.10.26',
v8: '3.14.5.8',
ares: '1.9.1',
uv: '0.10.25',
zlib: '1.2.7',
modules: '11',
openssl: '1.0.1e' }
root@.../sandbox-master/example# nodejs --version
v0.10.26
root@.../sandbox-master/example# nodejs example.js
Example 11: sending message into the sandbox 'hello from outside'
events.js:72
throw er; // Unhandled 'error' event
^
Error: write EPIPE
at errnoException (net.js:904:11)
at Object.afterWrite (net.js:720:19)
Hm...
ln -s /usr/bin/nodejs /usr/bin/node
helped with this error. As well as Sandbox.options.node = 'nodejs'.
The following script (run_stdin.js):
The following error when I run it:
If I replace stdin reading with direct
everything works fine.
How to deal with this?..