doc: console is asynchronous unless it's a file

Mea culpa, looks like I forgot to update console.markdown in commit
dac1d38 ("doc: stdout/stderr can block when directed to file").
This commit rectifies that.

Refs: https://github.com/nodejs/node/issues/5131
PR-URL: https://github.com/nodejs/node/pull/5133
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Evan Lucas <evanlucas@me.com>
pull/5133/head
Ben Noordhuis 2016-02-07 23:15:03 +01:00
parent 478c68284f
commit eaa9e0e776
1 changed files with 4 additions and 13 deletions

View File

@ -53,19 +53,10 @@ duplicate the browsers functionality exactly.
## Asynchronous vs Synchronous Consoles ## Asynchronous vs Synchronous Consoles
The console functions are synchronous when the destination is a terminal or The console functions are asynchronous unless the destination is a file.
a file (to avoid lost messages in case of premature exit) and asynchronous Disks are fast and operating systems normally employ write-back caching;
when the destination is a pipe (to avoid blocking for long periods of time). it should be a very rare occurrence indeed that a write blocks, but it
is possible.
In the following example, stdout is non-blocking while stderr is blocking:
```
$ node script.js 2> error.log | tee info.log
```
Typically, the distinction between blocking/non-blocking is not important
unless an application is logging significant amounts of data. High volume
logging *should* use a `Console` instance that writes to a pipe.
## Class: Console ## Class: Console