Skip to content
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

Ubuntu: stdout and stderr data is not emitted on child processes (with piped stdio) #42438

Closed
medikoo opened this issue Mar 22, 2022 · 4 comments
Labels
child_process Issues and PRs related to the child_process subsystem.

Comments

@medikoo
Copy link

medikoo commented Mar 22, 2022

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)

@medikoo medikoo changed the title Ubuntu: stdout and stderr data is not emitted on child processes (with piped stdin Ubuntu: stdout and stderr data is not emitted on child processes (with piped stdio) Mar 22, 2022
@ecalcutin
Copy link

ecalcutin commented Mar 22, 2022

I ran some tests on Windows / WSL2 Ubuntu ( just to confirm it works on Node 17.7.1)

uname -a
Linux RADIANT-XPS-17 5.10.60.1-microsoft-standard-WSL2 #1 SMP Wed Aug 25 23:20:18 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

works as expected
What is a reason you use nightly build ?

@medikoo
Copy link
Author

medikoo commented Mar 22, 2022

I've just looked more closely, and it appears only to Node.js as installed through snap dependency manager.

This probably should be coined as Ubuntu's Snap bug

@VoltrexKeyva VoltrexKeyva added the child_process Issues and PRs related to the child_process subsystem. label Mar 22, 2022
@giner
Copy link

giner commented Mar 2, 2023

Temporary workaround #37982 (comment)

@bnoordhuis
Copy link
Member

Closing, not a node bug.

@bnoordhuis bnoordhuis closed this as not planned Won't fix, can't repro, duplicate, stale Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
child_process Issues and PRs related to the child_process subsystem.
Projects
None yet
Development

No branches or pull requests

5 participants