Skip to content

Commit

Permalink
stream: validate abort signal
Browse files Browse the repository at this point in the history
PR-URL: #39346
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
  • Loading branch information
ronag committed Jul 12, 2021
1 parent de85b1e commit a5dec3a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/internal/streams/readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions lib/internal/streams/writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const { Buffer } = require('buffer');
const destroyImpl = require('internal/streams/destroy');

const {
addAbortSignalNoValidate,
addAbortSignal,
} = require('internal/streams/add-abort-signal');

const {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a5dec3a

Please sign in to comment.