Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,10 @@ Readable.prototype.read = function(n) {
debug('length less than watermark', doRead);
}

// However, if we've ended, then there's no point, and if we're already
// reading, then it's unnecessary.
if (state.ended || state.reading) {
// However, if we've ended, then there's no point, if we're already
// reading, then it's unnecessary, and if we're destroyed, then it's
// not allowed.
if (state.ended || state.reading || state.destroyed) {
doRead = false;
debug('reading or ended', doRead);
} else if (doRead) {
Expand Down
3 changes: 0 additions & 3 deletions lib/internal/fs/streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ ReadStream.prototype._read = function(n) {
});
}

if (this.destroyed)
return;

if (!pool || pool.length - pool.used < kMinPoolSpace) {
// Discard the old pool.
allocNewPool(this.readableHighWaterMark);
Expand Down
9 changes: 9 additions & 0 deletions test/parallel/test-stream-readable-destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,12 @@ const assert = require('assert');
read.push('hi');
read.on('data', common.mustNotCall());
}

{
const read = new Readable({
read: common.mustNotCall(function() {})
});
read.destroy();
assert.strictEqual(read.destroyed, true);
read.read();
}
2 changes: 1 addition & 1 deletion test/parallel/test-wrap-js-stream-exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ process.once('uncaughtException', common.mustCall((err) => {
}));

const socket = new JSStreamWrap(new Duplex({
read: common.mustCall(),
read: common.mustNotCall(),
write: common.mustCall((buffer, data, cb) => {
throw new Error('exception!');
})
Expand Down