summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Roberts <vieuxtech@gmail.com>2019-02-06 15:37:40 -0800
committerDaniel Bevenius <daniel.bevenius@gmail.com>2019-02-14 04:50:57 +0100
commit69a8e34003bdbc0c48e1079fb2c6a13f109011f1 (patch)
treea0811cbd3835c0c4f278d703195f966331c5d421
parentf4ce330f8f9d64ab8371352f1158ae9b502b5835 (diff)
downloadandroid-node-v8-69a8e34003bdbc0c48e1079fb2c6a13f109011f1.tar.gz
android-node-v8-69a8e34003bdbc0c48e1079fb2c6a13f109011f1.tar.bz2
android-node-v8-69a8e34003bdbc0c48e1079fb2c6a13f109011f1.zip
doc: clarify effect of stream.destroy() on write()
PR-URL: https://github.com/nodejs/node/pull/25973 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
-rw-r--r--doc/api/stream.md9
1 files changed, 7 insertions, 2 deletions
diff --git a/doc/api/stream.md b/doc/api/stream.md
index 9e20370528..14bc50d310 100644
--- a/doc/api/stream.md
+++ b/doc/api/stream.md
@@ -369,12 +369,17 @@ See also: [`writable.uncork()`][].
added: v8.0.0
-->
-* `error` {Error}
+* `error` {Error} Optional, an error to emit with `'error'` event.
* Returns: {this}
-Destroy the stream, and emit the passed `'error'` and a `'close'` event.
+Destroy the stream. Optionally emit an `'error'` event, and always emit
+a `'close'` event.
After this call, the writable stream has ended and subsequent calls
to `write()` or `end()` will result in an `ERR_STREAM_DESTROYED` error.
+This is a destructive and immediate way to destroy a stream. Previous calls to
+`write()` may not have drained, and may trigger an `ERR_STREAM_DESTROYED` error.
+Use `end()` instead of destroy if data should flush before close, or wait for
+the `'drain'` event before destroying the stream.
Implementors should not override this method,
but instead implement [`writable._destroy()`][writable-_destroy].