diff --git a/doc/api/process.markdown b/doc/api/process.markdown index 0c32799a66b6c6..f61e6e0f8696b2 100644 --- a/doc/api/process.markdown +++ b/doc/api/process.markdown @@ -286,6 +286,10 @@ event and that writes can block when output is redirected to a file (although disks are fast and operating systems normally employ write-back caching so it should be a very rare occurrence indeed.) +Note that on `process.stdout` and `process.stderr`, the callback passed to +`stream.write` might be called before all written data is flushed completely. +This can result in data loss if Node.js is ended prematurely using `process.exit`. + To check if Node.js is being run in a TTY context, read the `isTTY` property on `process.stderr`, `process.stdout`, or `process.stdin`: @@ -460,6 +464,10 @@ To exit with a 'failure' code: The shell that executed Node.js should see the exit code as 1. +Note that Node.js will shutdown as fast as possible. Consumers of `process.stdout` +and `process.stderr` might not get all data even when the `stream.write` callback +suggests different. + ## process.exitCode diff --git a/doc/api/stream.markdown b/doc/api/stream.markdown index 4dfc36e09e6648..fe3f099c3f14a7 100644 --- a/doc/api/stream.markdown +++ b/doc/api/stream.markdown @@ -566,6 +566,10 @@ even if it returns `false`. However, writes will be buffered in memory, so it is best not to do this excessively. Instead, wait for the `drain` event before writing more data. +Note that on `process.stdout` and `process.stderr` the callback might +be called before all data has been fully handled. This might result in +data loss if Node.js is ended via `process.exit`. + #### Event: 'drain' If a [`writable.write(chunk)`][] call returns false, then the `drain`