Files
bun.sh/test/js/node/async_hooks/async-context/async-context-stream-async-iterator.js
Jarred Sumner e1505b7143 Use JSC::Integrity:: auditCellFully in bindings (#22538)
### What does this PR do?

### How did you verify your code works?
2025-09-10 00:31:54 -07:00

30 lines
724 B
JavaScript

process.exitCode = 1;
const { AsyncLocalStorage } = require("async_hooks");
const { Readable } = require("stream");
const asyncLocalStorage = new AsyncLocalStorage();
asyncLocalStorage.run({ test: "stream.async.iterator" }, async () => {
const readable = new Readable({
read() {
this.push("a");
this.push("b");
this.push("c");
this.push(null);
},
});
try {
for await (const chunk of readable) {
if (asyncLocalStorage.getStore()?.test !== "stream.async.iterator") {
console.error("FAIL: stream async iterator lost context");
process.exit(1);
}
}
process.exit(0);
} catch (err) {
console.error("ERROR:", err);
process.exit(1);
}
});