Skip to content

Commit 8c19c23

Browse files
committed
doc: fix Writable.write callback description
Clarifies a userland invariant until a better solution can be found. Also moves a misplaced sentence from _write to write. Refs: nodejs#31756 Refs: nodejs#31765
1 parent 79296dc commit 8c19c23

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

doc/api/stream.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,8 @@ The `writable.write()` method writes some data to the stream, and calls the
585585
supplied `callback` once the data has been fully handled. If an error
586586
occurs, the `callback` *may or may not* be called with the error as its
587587
first argument. To reliably detect write errors, add a listener for the
588-
`'error'` event. If `callback` is called with an error, it will be called
589-
before the `'error'` event is emitted.
588+
`'error'` event. The `callback` method will always be called asynchronously
589+
and before `'error'` is emitted.
590590

591591
The return value is `true` if the internal buffer is less than the
592592
`highWaterMark` configured when the stream was created after admitting `chunk`.
@@ -1890,8 +1890,8 @@ methods only.
18901890
The `callback` method must be called to signal either that the write completed
18911891
successfully or failed with an error. The first argument passed to the
18921892
`callback` must be the `Error` object if the call failed or `null` if the
1893-
write succeeded. The `callback` method will always be called asynchronously and
1894-
before `'error'` is emitted.
1893+
write succeeded. The `callback` must be called synchronously inside of
1894+
`writable._write()` or asynchronously (i.e. different tick).
18951895

18961896
All calls to `writable.write()` that occur between the time `writable._write()`
18971897
is called and the `callback` is called will cause the written data to be

0 commit comments

Comments
 (0)