Skip to content

Commit fe41a9d

Browse files
committed
stream: fix finished regression when working with legacy Stream
Signed-off-by: Matteo Collina <hello@matteocollina.com>
1 parent d6c3a10 commit fe41a9d

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ function eos(stream, options, callback) {
171171
} else if (
172172
!writable &&
173173
(!willEmitClose || isWritable(stream)) &&
174-
(readableFinished || !isReadable(stream))
174+
(readableFinished || !isReadableNodeStream(stream))
175175
) {
176176
process.nextTick(onclose);
177177
} else if ((rState && stream.req && stream.aborted)) {

test/parallel/test-stream-finished.js

Lines 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)