Skip to content

Commit 6ade42b

Browse files
rexagodaddaleax
authored andcommitted
doc: stream.end(cb) cb can be invoked with error
Update docs that the optional callback passed to `writable.end` can be invoked in case of an error as well. PR-URL: #32238 Fixes: #31220 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent c37d4cc commit 6ade42b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

doc/api/stream.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@ Is `true` after [`writable.destroy()`][writable-destroy] has been called.
405405
<!-- YAML
406406
added: v0.9.4
407407
changes:
408+
- version: REPLACEME
409+
pr-url: https://github.com/nodejs/node/pull/29747
410+
description: The `callback` is invoked if 'finish' or 'error' is emitted.
408411
- version: v10.0.0
409412
pr-url: https://github.com/nodejs/node/pull/18780
410413
description: This method now returns a reference to `writable`.
@@ -418,14 +421,15 @@ changes:
418421
`Uint8Array`. For object mode streams, `chunk` may be any JavaScript value
419422
other than `null`.
420423
* `encoding` {string} The encoding if `chunk` is a string
421-
* `callback` {Function} Optional callback for when the stream is finished
424+
* `callback` {Function} Optional callback for when the stream finishes
425+
or errors
422426
* Returns: {this}
423427

424428
Calling the `writable.end()` method signals that no more data will be written
425429
to the [`Writable`][]. The optional `chunk` and `encoding` arguments allow one
426430
final additional chunk of data to be written immediately before closing the
427431
stream. If provided, the optional `callback` function is attached as a listener
428-
for the [`'finish'`][] event.
432+
for the [`'finish'`][] and the `'error'` event.
429433

430434
Calling the [`stream.write()`][stream-write] method after calling
431435
[`stream.end()`][stream-end] will raise an error.

0 commit comments

Comments
 (0)