diff options
author | Pranshu Srivastava <rexagod@gmail.com> | 2020-03-13 01:01:10 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2020-03-30 18:15:50 +0300 |
commit | 6ade42bb3c9d825d75fa9ef4300021a0b5b6ab08 (patch) | |
tree | c157d2d8dfa39ccb862f7331cc4155bf841d89c3 /doc | |
parent | c37d4ccee81084662dfb9311aa09a8d659b4f09e (diff) |
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: https://github.com/nodejs/node/pull/32238
Fixes: https://github.com/nodejs/node/issues/31220
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/stream.md | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/doc/api/stream.md b/doc/api/stream.md index 69be69b5516..7a54cead755 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -405,6 +405,9 @@ Is `true` after [`writable.destroy()`][writable-destroy] has been called. <!-- YAML added: v0.9.4 changes: + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/29747 + description: The `callback` is invoked if 'finish' or 'error' is emitted. - version: v10.0.0 pr-url: https://github.com/nodejs/node/pull/18780 description: This method now returns a reference to `writable`. @@ -418,14 +421,15 @@ changes: `Uint8Array`. For object mode streams, `chunk` may be any JavaScript value other than `null`. * `encoding` {string} The encoding if `chunk` is a string -* `callback` {Function} Optional callback for when the stream is finished +* `callback` {Function} Optional callback for when the stream finishes + or errors * Returns: {this} Calling the `writable.end()` method signals that no more data will be written to the [`Writable`][]. The optional `chunk` and `encoding` arguments allow one final additional chunk of data to be written immediately before closing the stream. If provided, the optional `callback` function is attached as a listener -for the [`'finish'`][] event. +for the [`'finish'`][] and the `'error'` event. Calling the [`stream.write()`][stream-write] method after calling [`stream.end()`][stream-end] will raise an error. |