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: fix finished regression when working with legacy Stream #40858

Merged
merged 2 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions lib/internal/streams/end-of-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ function eos(stream, options, callback) {
} else if (
!readable &&
(!willEmitClose || isReadable(stream)) &&
(writableFinished || !isWritable(stream))
(writableFinished || isWritable(stream) === false)
) {
process.nextTick(onclose);
} else if (
!writable &&
(!willEmitClose || isWritable(stream)) &&
(readableFinished || !isReadable(stream))
(readableFinished || isReadable(stream) === false)
) {
process.nextTick(onclose);
} else if ((rState && stream.req && stream.aborted)) {
Expand Down
11 changes: 10 additions & 1 deletion test/parallel/test-stream-finished.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const {
Transform,
finished,
Duplex,
PassThrough
PassThrough,
Stream
mcollina marked this conversation as resolved.
Show resolved Hide resolved
} = require('stream');
const assert = require('assert');
const EE = require('events');
Expand Down Expand Up @@ -630,3 +631,11 @@ testClosed((opts) => new Writable({ write() {}, ...opts }));
}));
}));
}

{
// Legacy Streams do not inherit from Readable or Writable.
// We cannot really assume anything about them, so we cannot close them
// automatically.
const s = new Stream();
finished(s, common.mustNotCall());
}