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: https://github.com/nodejs/node/pull/45026
Fixes: https://github.com/nodejs/node/issues/42694
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
David Halls authored and GitHub committed 2022-10-22 17:27:37 +00:00
1 parent 3a4f964930
commit 538d8ce106
2 files changed
+26 -5

No files matched your search

-5
View File
@@ -32,7 +32,6 @@ const {
const {
isDestroyed,
isReadable,
isReadableEnded,
isWritable,
isWritableEnded,
} = require('internal/streams/utils');
@@ -528,8 +527,6 @@ function newStreamReadableFromReadableStream(readableStream, options = kEmptyObj
reader.closed,
() => {
closed = true;
if (!isReadableEnded(readable))
readable.push(null);
},
(error) => {
closed = true;
@@ -794,8 +791,6 @@ function newStreamDuplexFromReadableWritablePair(pair = kEmptyObject, options =
reader.closed,
() => {
readableClosed = true;
if (!isReadableEnded(duplex))
duplex.push(null);
},
(error) => {
writableClosed = true;