-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
1 parent
896b48b
commit c514751
Showing
2 changed files
with
26 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
test/parallel/test-readable-from-web-enqueue-then-close.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); |