Skip to content

Commit d1c45e2

Browse files
AriLFrankeltargos
authored andcommitted
doc: update child_process.md
Add an explanation of the risk of exceeding platform pipe capacity with uncaptured output in child_process.spawn with stdio of pipe PR-URL: #19075 Fixes: #4236 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 8e3f59f commit d1c45e2

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

doc/api/child_process.md

+10-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,16 @@ ls.on('close', (code) => {
2727
```
2828

2929
By default, pipes for `stdin`, `stdout`, and `stderr` are established between
30-
the parent Node.js process and the spawned child. It is possible to stream data
31-
through these pipes in a non-blocking way. *Note, however, that some programs
32-
use line-buffered I/O internally. While that does not affect Node.js, it can
33-
mean that data sent to the child process may not be immediately consumed.*
30+
the parent Node.js process and the spawned child. These pipes have
31+
limited (and platform-specific) capacity. If the child process writes to
32+
stdout in excess of that limit without the output being captured, the child
33+
process will block waiting for the pipe buffer to accept more data. This is
34+
identical to the behavior of pipes in the shell. Use the `{ stdio: 'ignore' }`
35+
option if the output will not be consumed.
36+
It is possible to stream data through these pipes in a non-blocking way. Note,
37+
however, that some programs use line-buffered I/O internally. While that does
38+
not affect Node.js, it can mean that data sent to the child process may not be
39+
immediately consumed.
3440

3541
The [`child_process.spawn()`][] method spawns the child process asynchronously,
3642
without blocking the Node.js event loop. The [`child_process.spawnSync()`][]

0 commit comments

Comments
 (0)