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: don't push null from closed promise #42694 #45026

Merged
merged 1 commit into from Oct 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 0 additions & 5 deletions lib/internal/webstreams/adapters.js
Expand Up @@ -32,7 +32,6 @@ const {
const {
isDestroyed,
isReadable,
isReadableEnded,
isWritable,
isWritableEnded,
} = require('internal/streams/utils');
Expand Down Expand Up @@ -528,8 +527,6 @@ function newStreamReadableFromReadableStream(readableStream, options = kEmptyObj
reader.closed,
() => {
closed = true;
if (!isReadableEnded(readable))
readable.push(null);
},
(error) => {
closed = true;
Expand Down Expand Up @@ -794,8 +791,6 @@ function newStreamDuplexFromReadableWritablePair(pair = kEmptyObject, options =
reader.closed,
() => {
readableClosed = true;
if (!isReadableEnded(duplex))
duplex.push(null);
},
(error) => {
writableClosed = true;
Expand Down
26 changes: 26 additions & 0 deletions test/parallel/test-readable-from-web-enqueue-then-close.js
@@ -0,0 +1,26 @@
'use strict';
const { mustCall } = require('../common');
const { Readable, Duplex } = require('stream');
const { strictEqual } = require('assert');

function start(controller) {
controller.enqueue(new Uint8Array(1));
controller.close();
}

Readable.fromWeb(new ReadableStream({ start }))
.on('data', mustCall((d) => {
strictEqual(d.length, 1);
}))
.on('end', mustCall())
.resume();

Duplex.fromWeb({
readable: new ReadableStream({ start }),
writable: new WritableStream({ write(chunk) {} })
})
.on('data', mustCall((d) => {
strictEqual(d.length, 1);
}))
.on('end', mustCall())
.resume();