Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream: cleanup use of _readableState.ended #29645

Closed
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
2 changes: 1 addition & 1 deletion lib/internal/http2/compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ class Http2ServerRequest extends Readable {

get complete() {
return this[kAborted] ||
this._readableState.ended ||
this.readableEnded ||
this[kState].closed ||
this[kStream].destroyed;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,11 @@ class Worker extends EventEmitter {

const { stdout, stderr } = this[kParentSideStdio];

if (!stdout._readableState.ended) {
if (!stdout.readableEnded) {
debug(`[${threadId}] explicitly closes stdout for ${this.threadId}`);
stdout.push(null);
}
if (!stderr._readableState.ended) {
if (!stderr.readableEnded) {
debug(`[${threadId}] explicitly closes stderr for ${this.threadId}`);
stderr.push(null);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ function afterShutdown(status) {
if (self.destroyed)
return;

if (!self.readable || self._readableState.ended) {
if (!self.readable || self.readableEnded) {
debug('readableState ended, destroying');
self.destroy();
}
Expand Down
13 changes: 13 additions & 0 deletions test/parallel/test-stream-readable-ended.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,16 @@ const assert = require('assert');
assert.strictEqual(readable.readableEnded, false);
}));
}

// Verifies no `error` triggered on multiple .push(null) invocations
{
const readable = new Readable();

readable.on('readable', () => { readable.read(); });
readable.on('error', common.mustNotCall());
readable.on('end', common.mustCall());

readable.push('a');
readable.push(null);
readable.push(null);
}