Version
v18.0.0-nightly20220311d8c4e375f2
Platform
Linux parallels-Parallels-Virtual-Platform 5.13.0-37-generic #42~20.04.1-Ubuntu SMP Tue Mar 15 15:44:28 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
Run node main.js having following two files in same folder:
child.js
console.log("Some text");
const interval = setInterval(() => {
console.log("Other text")
}, 100)
setTimeout(() => clearInterval(interval), 1000);
main.js
const childProcess = require('child_process');
const child = childProcess.spawn('node', ['child.js'], { stdio: 'pipe'});
if (child.stdout) {
console.log("Attach std listeners")
child.stdout.on('data', data => console.log("Child stdout:", String(data)));
child.stderr.on('data', data => console.log("Child stderr:", String(data)));
}
child.on('close', (...args) => { console.log("Child closed", args); });
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
Expected output (e.g. observable on macOS) is:
Attach std listeners
Child stdout: Some text
Child stdout: Other text
Child stdout: Other text
Child stdout: Other text
Child stdout: Other text
Child stdout: Other text
Child stdout: Other text
Child stdout: Other text
Child stdout: Other text
Child stdout: Other text
Child closed [ 0, null ]
What do you see instead?
Attach std listeners
CLOSED [ 0, null ]
Additional information
When stdio is set to inherit then the child output is exposed as expected.
I observe it on every Node.js version I've tried (v14, v16, v17, and latest build)
Version
v18.0.0-nightly20220311d8c4e375f2Platform
Linux parallels-Parallels-Virtual-Platform 5.13.0-37-generic #42~20.04.1-Ubuntu SMP Tue Mar 15 15:44:28 UTC 2022 x86_64 x86_64 x86_64 GNU/LinuxSubsystem
No response
What steps will reproduce the bug?
Run
node main.jshaving following two files in same folder:child.js
main.js
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
Expected output (e.g. observable on macOS) is:
What do you see instead?
Additional information
When
stdiois set toinheritthen the child output is exposed as expected.I observe it on every Node.js version I've tried (v14, v16, v17, and latest build)