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 1655532

Browse filesBrowse files
davedoesdevRafaelGSS
authored andcommitted
stream: don't push null from closed promise #42694
closed promise is subscribed to first so will be resolved first, before any read promise. This causes data after EOF error to be thrown. Remove the push null from the closed promise handler. The push null gets done from the read handler when it detects done. PR-URL: #45026 Fixes: #42694 Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 809e8dc commit 1655532
Copy full SHA for 1655532

File tree

Expand file treeCollapse file tree

2 files changed

+26
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+26
-5
lines changed
Open diff view settings
Collapse file

‎lib/internal/webstreams/adapters.js‎

Copy file name to clipboardExpand all lines: lib/internal/webstreams/adapters.js
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ const {
3232
const {
3333
isDestroyed,
3434
isReadable,
35-
isReadableEnded,
3635
isWritable,
3736
isWritableEnded,
3837
} = require('internal/streams/utils');
@@ -528,8 +527,6 @@ function newStreamReadableFromReadableStream(readableStream, options = kEmptyObj
528527
reader.closed,
529528
() => {
530529
closed = true;
531-
if (!isReadableEnded(readable))
532-
readable.push(null);
533530
},
534531
(error) => {
535532
closed = true;
@@ -794,8 +791,6 @@ function newStreamDuplexFromReadableWritablePair(pair = kEmptyObject, options =
794791
reader.closed,
795792
() => {
796793
readableClosed = true;
797-
if (!isReadableEnded(duplex))
798-
duplex.push(null);
799794
},
800795
(error) => {
801796
writableClosed = true;
Collapse file
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict';
2+
const { mustCall } = require('../common');
3+
const { Readable, Duplex } = require('stream');
4+
const { strictEqual } = require('assert');
5+
6+
function start(controller) {
7+
controller.enqueue(new Uint8Array(1));
8+
controller.close();
9+
}
10+
11+
Readable.fromWeb(new ReadableStream({ start }))
12+
.on('data', mustCall((d) => {
13+
strictEqual(d.length, 1);
14+
}))
15+
.on('end', mustCall())
16+
.resume();
17+
18+
Duplex.fromWeb({
19+
readable: new ReadableStream({ start }),
20+
writable: new WritableStream({ write(chunk) {} })
21+
})
22+
.on('data', mustCall((d) => {
23+
strictEqual(d.length, 1);
24+
}))
25+
.on('end', mustCall())
26+
.resume();

0 commit comments

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