diff --git a/lib/internal/streams/readable.js b/lib/internal/streams/readable.js index 22a644b3f3383c..0e822c71a62e06 100644 --- a/lib/internal/streams/readable.js +++ b/lib/internal/streams/readable.js @@ -43,7 +43,7 @@ const { Stream, prependListener } = require('internal/streams/legacy'); const { Buffer } = require('buffer'); const { - addAbortSignalNoValidate, + addAbortSignal, } = require('internal/streams/add-abort-signal'); const eos = require('internal/streams/end-of-stream'); @@ -199,8 +199,9 @@ function Readable(options) { if (typeof options.construct === 'function') this._construct = options.construct; + if (options.signal && !isDuplex) - addAbortSignalNoValidate(options.signal, this); + addAbortSignal(options.signal, this); } Stream.call(this, options); diff --git a/lib/internal/streams/writable.js b/lib/internal/streams/writable.js index 03f63b16bd04ff..0a7e72b93f2e31 100644 --- a/lib/internal/streams/writable.js +++ b/lib/internal/streams/writable.js @@ -46,7 +46,7 @@ const { Buffer } = require('buffer'); const destroyImpl = require('internal/streams/destroy'); const { - addAbortSignalNoValidate, + addAbortSignal, } = require('internal/streams/add-abort-signal'); const { @@ -249,8 +249,9 @@ function Writable(options) { if (typeof options.construct === 'function') this._construct = options.construct; + if (options.signal) - addAbortSignalNoValidate(options.signal, this); + addAbortSignal(options.signal, this); } Stream.call(this, options);