@@ -1938,6 +1938,9 @@ method.
19381938#### ` new stream.Writable([options]) `
19391939<!-- YAML
19401940changes:
1941+ - version: REPLACEME
1942+ pr-url: https://github.com/nodejs/node/pull/36431
1943+ description: support passing in an AbortSignal.
19411944 - version: v14.0.0
19421945 pr-url: https://github.com/nodejs/node/pull/30623
19431946 description: Change `autoDestroy` option default to `true`.
@@ -1985,6 +1988,7 @@ changes:
19851988 [ ` stream._construct() ` ] [ writable-_construct ] method.
19861989 * ` autoDestroy ` {boolean} Whether this stream should automatically call
19871990 ` .destroy() ` on itself after ending. ** Default:** ` true ` .
1991+ * ` signal ` {AbortSignal} A signal representing possible cancellation.
19881992
19891993<!-- eslint-disable no-useless-constructor -->
19901994``` js
@@ -2028,6 +2032,27 @@ const myWritable = new Writable({
20282032});
20292033```
20302034
2035+ Calling ` abort ` on the ` AbortController ` corresponding to the passed
2036+ ` AbortSignal ` will behave the same way as calling ` .destroy(new AbortError()) `
2037+ on the writeable stream.
2038+
2039+ ``` js
2040+ const { Writable } = require (' stream' );
2041+
2042+ const controller = new AbortController ();
2043+ const myWritable = new Writable ({
2044+ write (chunk , encoding , callback ) {
2045+ // ...
2046+ },
2047+ writev (chunks , callback ) {
2048+ // ...
2049+ },
2050+ signal: controller .signal
2051+ });
2052+ // Later, abort the operation closing the stream
2053+ controller .abort ();
2054+
2055+ ```
20312056#### ` writable._construct(callback) `
20322057<!-- YAML
20332058added: v15.0.0
@@ -2276,6 +2301,9 @@ constructor and implement the [`readable._read()`][] method.
22762301#### ` new stream.Readable([options]) `
22772302<!-- YAML
22782303changes:
2304+ - version: REPLACEME
2305+ pr-url: https://github.com/nodejs/node/pull/36431
2306+ description: support passing in an AbortSignal.
22792307 - version: v14.0.0
22802308 pr-url: https://github.com/nodejs/node/pull/30623
22812309 description: Change `autoDestroy` option default to `true`.
@@ -2306,6 +2334,7 @@ changes:
23062334 [ ` stream._construct() ` ] [ readable-_construct ] method.
23072335 * ` autoDestroy ` {boolean} Whether this stream should automatically call
23082336 ` .destroy() ` on itself after ending. ** Default:** ` true ` .
2337+ * ` signal ` {AbortSignal} A signal representing possible cancellation.
23092338
23102339<!-- eslint-disable no-useless-constructor -->
23112340``` js
@@ -2346,6 +2375,23 @@ const myReadable = new Readable({
23462375});
23472376```
23482377
2378+ Calling ` abort ` on the ` AbortController ` corresponding to the passed
2379+ ` AbortSignal ` will behave the same way as calling ` .destroy(new AbortError()) `
2380+ on the readable created.
2381+
2382+ ``` js
2383+ const fs = require (' fs' );
2384+ const controller = new AbortController ();
2385+ const read = new Readable ({
2386+ read (size ) {
2387+ // ...
2388+ },
2389+ signal: controller .signal
2390+ });
2391+ // Later, abort the operation closing the stream
2392+ controller .abort ();
2393+ ```
2394+
23492395#### ` readable._construct(callback) `
23502396<!-- YAML
23512397added: v15.0.0
0 commit comments