Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 534409d

Browse filesBrowse files
mcollinatargos
authored andcommitted
stream: fix finished regression when working with legacy Stream
Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: #40858 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent 90f35fc commit 534409d
Copy full SHA for 534409d

File tree

Expand file treeCollapse file tree

2 files changed

+12
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-3
lines changed
Open diff view settings
Collapse file

‎lib/internal/streams/end-of-stream.js‎

Copy file name to clipboardExpand all lines: lib/internal/streams/end-of-stream.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,13 @@ function eos(stream, options, callback) {
165165
} else if (
166166
!readable &&
167167
(!willEmitClose || isReadable(stream)) &&
168-
(writableFinished || !isWritable(stream))
168+
(writableFinished || isWritable(stream) === false)
169169
) {
170170
process.nextTick(onclose);
171171
} else if (
172172
!writable &&
173173
(!willEmitClose || isWritable(stream)) &&
174-
(readableFinished || !isReadable(stream))
174+
(readableFinished || isReadable(stream) === false)
175175
) {
176176
process.nextTick(onclose);
177177
} else if ((rState && stream.req && stream.aborted)) {
Collapse file

‎test/parallel/test-stream-finished.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream-finished.js
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ const {
77
Transform,
88
finished,
99
Duplex,
10-
PassThrough
10+
PassThrough,
11+
Stream,
1112
} = require('stream');
1213
const assert = require('assert');
1314
const EE = require('events');
@@ -630,3 +631,11 @@ testClosed((opts) => new Writable({ write() {}, ...opts }));
630631
}));
631632
}));
632633
}
634+
635+
{
636+
// Legacy Streams do not inherit from Readable or Writable.
637+
// We cannot really assume anything about them, so we cannot close them
638+
// automatically.
639+
const s = new Stream();
640+
finished(s, common.mustNotCall());
641+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.