-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Stdout is not completely flushed on process exit #2972
Comments
It's not clear to me from the above issues that they refer to the same regression between 0.12 and 4.0. In #2148, you mention the same problem occurs with 0.12 (this is not the case here). #1741 and #2148 are also about writing to stdout/err in a loop. The test case above writes a single string to stdout. It fails when the string is 8193 bytes. It passes at 8192. And this only occurs with Node 4 (not 0.10 or 0.12). |
The issue is that |
Forgot to mention, in your example you can fix the issue by dropping the immediate |
Thanks for the extra detail @bnoordhuis. Still curious what exactly changed since 0.12 that causes the test above to fail at 8192 bytes. Any chance this size is configurable? In my case, I cannot change where |
Stdio is fully asynchronous now (and that's not configurable.) It used to be synchronous, mostly, but with so many caveats that even core team members often didn't know when it would or wouldn't be. |
Thanks @bnoordhuis. It looks like the code from 20176a9 is still there, and the docs were recently changed to say that It sounds like the only way to ensure that |
Oh dear, this again.
Yes.
That's when something at OS(?)-level starts breaking it into chunks. |
(Closing as a dupe, feel free to continue discussing) |
Also, updated the breaking change documentation on this: https://github.com/nodejs/node/wiki/API-changes-between-v0.10-and-v4#process |
For people coming here from Google, this:
Is correct at the time of writing, except when stdio is redirected to a file. That includes special files like /dev/null and /dev/zero but excludes /dev/tty, /dev/stdout, etc. and bash's /dev/tcp pseudo-files. See also #3170, where I was very careful to use the word 'may' in 'may block'. :-) |
`process.exit` quits immediately, without allowing buffered output from say, a `console.log` to be printed. See these Node.js issues: nodejs/node#3669 nodejs/node#3170 nodejs/node#2972 (comment)
See #6456 for the latest. |
`process.exit` can truncate long output in certain node versions, see these tickets: nodejs/node#3669 nodejs/node#3170 nodejs/node#2972 (comment) fixes #161
The following fails with Node 4.1 (but passes on 0.12 and 0.10) on OS 10.10.5:
The child writes 8193 bytes to stdout. The parent only gets 8192 before the exit.
See also nodejs/node-v0.x-archive#8329.
The text was updated successfully, but these errors were encountered: