-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
Closed
Labels
child_processIssues and PRs related to the child_process subsystem.Issues and PRs related to the child_process subsystem.
Description
- Version:
v8.4.0
- Platform:
Darwin duplo 15.6.0 Darwin Kernel Version 15.6.0: Tue Apr 11 16:00:51 PDT 2017; root:xnu-3248.60.11.5.3~1/RELEASE_X86_64 x86_64
- Subsystem: net, stream or child_process (?)
Tested with:
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)
GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu)
Not sure is this the same or another bug but in my environment it throws:
Error: write EPIPE
at _errnoException (util.js:1041:11)
at WriteWrap.afterWrite [as oncomplete] (net.js:858:14)
But when we played with it a little:
Error: This socket has been ended by the other party
at Socket.writeAfterFIN [as write] (net.js:352:12)
at __dirname (/Users/qfox/repos/trendbox-ci/omg.js:11:11)
at <anonymous>
How to repro:
const { spawn } = require('child_process');
const pause = t => new Promise(resolve => setTimeout(resolve, t));
const { stdin } = spawn('bash', [/*'-i'*/], { stdio: ['pipe', 'inherit'] });
(async () => {
stdin.write('echo All is fine here\n');
await pause(200);
stdin.write('node -e process.stdin && echo After process.stdin\n');
await pause(2000); // It's important: the bigger pause, the more frequently occurs
stdin.write('echo After all\n');
})().catch(e => console.error(e.stack));
If we remove usage of process.stdin
or force shell to be interactive (pass in ['-i']
flag) or just call node -e process.stdin
with </dev/stdin
— then the problem disappears.
Would be nice to have a good error message if it's unfixable ;'-(
Metadata
Metadata
Assignees
Labels
child_processIssues and PRs related to the child_process subsystem.Issues and PRs related to the child_process subsystem.