Skip to content

Commit 8de9fe9

Browse files
tadjik1targos
authored andcommitted
doc: document error event is optionally emitted after .destroy()
`error` event on each kind of stream is optionally emitted when `.destroy()` method is called. It depends on `._destroy()` implementation. In default implementation this event will no be fired unless `error` parameter has been provided. It was already mentioned for `writable.destroy([error])`, so I just copied same sentence for the other streams. PR-URL: #26589 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 0e4ae00 commit 8de9fe9

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

doc/api/stream.md

+11-9
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,10 @@ added: v8.0.0
372372
* `error` {Error} Optional, an error to emit with `'error'` event.
373373
* Returns: {this}
374374

375-
Destroy the stream. Optionally emit an `'error'` event, and always emit
376-
a `'close'` event.
377-
After this call, the writable stream has ended and subsequent calls
378-
to `write()` or `end()` will result in an `ERR_STREAM_DESTROYED` error.
375+
Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'`
376+
event unless `emitClose` is set in `false`. After this call, the writable
377+
stream has ended and subsequent calls to `write()` or `end()` will result in
378+
an `ERR_STREAM_DESTROYED` error.
379379
This is a destructive and immediate way to destroy a stream. Previous calls to
380380
`write()` may not have drained, and may trigger an `ERR_STREAM_DESTROYED` error.
381381
Use `end()` instead of destroy if data should flush before close, or wait for
@@ -876,9 +876,10 @@ added: v8.0.0
876876
* `error` {Error} Error which will be passed as payload in `'error'` event
877877
* Returns: {this}
878878

879-
Destroy the stream, and emit `'error'` and `'close'`. After this call, the
880-
readable stream will release any internal resources and subsequent calls
881-
to `push()` will be ignored.
879+
Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'`
880+
event unless `emitClose` is set in `false`. After this call, the readable
881+
stream will release any internal resources and subsequent calls to `push()`
882+
will be ignored.
882883
Implementors should not override this method, but instead implement
883884
[`readable._destroy()`][readable-_destroy].
884885

@@ -1342,11 +1343,12 @@ added: v8.0.0
13421343
-->
13431344
* `error` {Error}
13441345

1345-
Destroy the stream, and emit `'error'`. After this call, the
1346+
Destroy the stream, and optionally emit an `'error'` event. After this call, the
13461347
transform stream would release any internal resources.
13471348
Implementors should not override this method, but instead implement
13481349
[`readable._destroy()`][readable-_destroy].
1349-
The default implementation of `_destroy()` for `Transform` also emit `'close'`.
1350+
The default implementation of `_destroy()` for `Transform` also emit `'close'`
1351+
unless `emitClose` is set in false.
13501352

13511353
### stream.finished(stream[, options], callback)
13521354
<!-- YAML

0 commit comments

Comments
 (0)