Skip to content

Commit

Permalink
stream: fix non readable Duplex readableAborted
Browse files Browse the repository at this point in the history
PR-URL: #40801
Fixes: #40800
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
ronag authored and targos committed Nov 21, 2021
1 parent e451ec9 commit 7d127d2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/internal/streams/readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
},

Expand Down
11 changes: 10 additions & 1 deletion test/parallel/test-stream-readable-aborted.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -55,3 +55,12 @@ const { Readable } = require('stream');
}));
readable.resume();
}

{
const duplex = new Duplex({
readable: false,
write() {}
});
duplex.destroy();
assert.strictEqual(duplex.readableAborted, false);
}

0 comments on commit 7d127d2

Please sign in to comment.