-
-
Notifications
You must be signed in to change notification settings - Fork 203
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
result.stdout
is empty while result.all
is not
#322
Comments
result.stdout
is empty when it was not expected toresult.stdout
is empty while result.all
is not
Reduced the issue to the following code (which is based on what const childProcess = require('child_process');
const getStream = require('get-stream');
const mergeStream = require('merge-stream');
const bug = async () => {
const spawned = childProcess.spawn('echo', ['test']);
const allStream = mergeStream(spawned.stdout);
spawned.on('exit', async () => {
const stdout = await getStream(spawned.stdout);
const all = await getStream(allStream);
console.log({stdout, all});
});
};
bug(); $ node bug.js
{ stdout: '', all: 'test\n' } |
The problem might be the following: when a A closed stream cannot be read from nor piped from. However On one hand child process streams being cleaned up on exit is a good thing as it prevents memory leak. On the other hand there might be cases where users might want to defer a child process streams consumption, e.g. when it is passed to another consumer. We could stop deferring stream consumption, but that has issues as well. @sindresorhus I would need your feedback on this as this is tricky. A second related (but distinct) issue is that this does not apply to
I think this we should deal with the first problem before checking out what's happening with |
The second issue seems to be because |
PR at #351. |
This is not an issue, see #351 (comment) |
Steps to reproduce:
$ node index.js stdout: stderr: all: test
Node
v12.4.0
Ubuntu
19.10
Execa
2.0.0
The text was updated successfully, but these errors were encountered: