From 7d127d2fc1e59b0d605e48391716c4d2d7cc94c6 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Sat, 13 Nov 2021 15:04:35 +0200 Subject: [PATCH] stream: fix non readable Duplex readableAborted MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/40801 Fixes: https://github.com/nodejs/node/issues/40800 Reviewed-By: Juan José Arboleda Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Matteo Collina --- lib/internal/streams/readable.js | 7 +++++-- test/parallel/test-stream-readable-aborted.js | 11 ++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/internal/streams/readable.js b/lib/internal/streams/readable.js index 3d37f277a37779..051441f015daa0 100644 --- a/lib/internal/streams/readable.js +++ b/lib/internal/streams/readable.js @@ -1187,8 +1187,11 @@ ObjectDefineProperties(Readable.prototype, { readableAborted: { enumerable: false, get: function() { - return !!(this._readableState.destroyed || this._readableState.errored) && - !this._readableState.endEmitted; + return !!( + this._readableState.readable !== false && + (this._readableState.destroyed || this._readableState.errored) && + !this._readableState.endEmitted + ); } }, diff --git a/test/parallel/test-stream-readable-aborted.js b/test/parallel/test-stream-readable-aborted.js index 8915e07de45373..9badffc51fc424 100644 --- a/test/parallel/test-stream-readable-aborted.js +++ b/test/parallel/test-stream-readable-aborted.js @@ -2,7 +2,7 @@ const common = require('../common'); const assert = require('assert'); -const { Readable } = require('stream'); +const { Readable, Duplex } = require('stream'); { const readable = new Readable({ @@ -55,3 +55,12 @@ const { Readable } = require('stream'); })); readable.resume(); } + +{ + const duplex = new Duplex({ + readable: false, + write() {} + }); + duplex.destroy(); + assert.strictEqual(duplex.readableAborted, false); +}