From f777936465d2a88c863096a17f141ebc685464f6 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Sat, 10 Jul 2021 21:28:47 +0200 Subject: [PATCH] stream: validate abort signal --- lib/internal/streams/readable.js | 5 +++-- lib/internal/streams/writable.js | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) 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);