-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
child-process: data loss with piped stdout #7184
Comments
This commit prevents child process stdio streams from being automatically flushed on child process exit/close if a piped consumer has been attached at the time of exit. Without this, child process stdio data can be lost if the process exits quickly and the piped consumer hasn't had the chance to read the remaining data. Fixes: nodejs#7184 Signed-off-by: Petros Angelatos <[email protected]>
Can you try using the close event instead of exit? |
@evanlucas the close event is never emitted. @addaleax I think it's a different issue. I just pushed a PR and testcase that fixes the issue for me |
@petrosagg Yeah, I see that, and I also understand why your PR fixes the issue, but I still think the underlying issue stems from the streams implementation, not from child processes. You can through the description of #7160 if you want to understand why the |
@petrosagg |
@addaleax I'm trying to understand how back-pressure works when one calls |
@petrosagg Well, I think that’s what supposed to happen, and #7160 would ensure that behaviour. |
Closing as a duplicate but feel free to keep asking if there’s anything unclear :) |
@addaleax I was studying your testcase. Everything makes sense now. Thanks for the explanation :) |
When the stdout of a spawned process is piped into a writable stream that doesn't read fast enough, and the spawned process exits, node will put it into flowing mode and data will be lost.
I have the following minimal testcase that pipes a simple child process to a PassThrough stream, and only after the process has exited the through stream is piped to node's stdout.
The text was updated successfully, but these errors were encountered: