-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
doc: stdout/stderr can block when directed to file #3170
Conversation
For anyone wondering why stdio to file is a special case: asynchronous file writes need to be done from another thread. Applications that log a lot can easily overwhelm the thread pool. |
See also #1741 — without redirecting, applications that log a lot can consume all the memory. |
Things get a lot worse when everything has to go through the thread pool first, though. Can I get a LGTM? |
Umm, can we at least list some cases when it does and doesn't block? |
I don't mind expanding if you can give me some pointers on what you want it to look like. It's nuanced, though. Writes to a file don't normally block because of write-back caching, so you don't want to give off an impression that stdio-to-file is always bad. |
@Fishrock123 Ping? |
Given this causes people grief time and again as seen by various issues, maybe you could add some info in like this? When it blocks to regular terminal stdout or not is probably the most important, followed by redirected to a file. I think it's worth explaining in good detail here, if possible. |
beb3f0f
to
7947b6c
Compare
@Fishrock123 Updated, PTAL. |
Ugh, maybe my memory is failing but I thought it was blocking in more instances too? :/ otherwise LGTM. |
Update the documentation for `process.stdout` and `process.stdout` to clarify that writes can block when stdio is redirected to a file. In all other cases, it's non-blocking. PR-URL: nodejs#3170 Reviewed-By: Jeremiah Senkpiel <[email protected]>
7947b6c
to
dac1d38
Compare
Update the documentation for `process.stdout` and `process.stdout` to clarify that writes can block when stdio is redirected to a file. In all other cases, it's non-blocking. PR-URL: #3170 Reviewed-By: Jeremiah Senkpiel <[email protected]>
Update the documentation for `process.stdout` and `process.stdout` to clarify that writes can block when stdio is redirected to a file. In all other cases, it's non-blocking. PR-URL: #3170 Reviewed-By: Jeremiah Senkpiel <[email protected]>
landed in lts-v4.x-staging as 38a5ae1 |
Update the documentation for `process.stdout` and `process.stdout` to clarify that writes can block when stdio is redirected to a file. In all other cases, it's non-blocking. PR-URL: #3170 Reviewed-By: Jeremiah Senkpiel <[email protected]>
Update the documentation for `process.stdout` and `process.stdout` to clarify that writes can block when stdio is redirected to a file. In all other cases, it's non-blocking. PR-URL: #3170 Reviewed-By: Jeremiah Senkpiel <[email protected]>
Update the documentation for `process.stdout` and `process.stdout` to clarify that writes can block when stdio is redirected to a file. In all other cases, it's non-blocking. PR-URL: #3170 Reviewed-By: Jeremiah Senkpiel <[email protected]>
`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)
`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
Update the documentation for
process.stdout
andprocess.stdout
toclarify that writes can block when stdio is redirected to a file. In
all other cases, it's non-blocking.