-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Open
Description
Version
22.20.0
Platform
Darwin Patricks-Laptop.local 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6000 arm64
Subsystem
streams
What steps will reproduce the bug?
Assuming a file.txt on disk that contains random text (e.g. hello), the following script will appropriately hit the catch block in Node 22.4.1 but not in Node versions after (including current LTS 22.20.0). I believe it is related to this change: #53462
import { createReadStream } from "node:fs";
const fileStream = createReadStream("./file.txt", {
encoding: "utf8",
});
const composedStreamOne = async function* (objectStream) {
for await (const obj of objectStream) {
throw new Error("Intentional error in composedStreamOne");
}
};
const composedStreamTwo = async function* (objectStream) {
for await (const obj of objectStream) {
yield obj + "goodbye";
}
};
const composed = fileStream
.compose(composedStreamOne)
.compose(composedStreamTwo);
try {
for await (const text of composed) {
console.log("String is:", text);
}
} catch (err) {
console.error("Caught error:", err.message);
}In Node 22.4.1 we get:
node -v && node compose.mjs
v22.4.1
Caught error: Intentional error in composedStreamOne
In Node 22.5.0+ we get:
node -v && node compose.mjs
v22.5.0
Warning: Detected unsettled top-level await at file:///Users/patrickshipe/projects/compose-bug/compose.mjs:24
for await (const text of composed) {
How often does it reproduce? Is there a required condition?
It will reproduce 100% of the time when composing streams like this.
What is the expected behavior? Why is that the expected behavior?
The expected behavior is that the composed stream will correctly bubble up an error in any of the constituent streams.
What do you see instead?
The script will never complete, or fail on unsettled top-level await if at the top level.
Additional information
No response
gimbalgambit, borahdora, bmcarr928, jteske-redox and blakerego
Metadata
Metadata
Assignees
Labels
No labels