- From: lukasIO <notifications@github.com>
- Date: Thu, 17 Apr 2025 03:38:48 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Thursday, 17 April 2025 10:38:52 UTC
lukasIO created an issue (whatwg/streams#1343)
### What is the issue with the Streams Standard?
Is it intended by the spec that breaking async iteration of a teed streams halts the execution of the program?
```ts
const rs = new ReadableStream({
start(controller) {
let i = 0;
const interval = setInterval(() => {
controller.enqueue(i++);
}, 100);
// Clean up when canceled
this._cancel = () => {
clearInterval(interval);
console.log('cancelled');
};
},
cancel(reason) {
console.log('cancel() called with', reason);
this._cancel?.();
return Promise.resolve();
},
});
const [r1, r2] = rs.tee();
let i = 0;
(async () => {
for await (const val of r1) {
console.log('r1', val);
if (i++ > 2) {
console.log('breaking r1');
break;
}
}
console.log('finished r1 loop');
})();
```
Right now in all environments I tested in (browsers and across NodeJS versions) the last log I get is `"breaking r1"` - `finished r1 loop` never gets logged
--
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/1343
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/streams/issues/1343@github.com>
Received on Thursday, 17 April 2025 10:38:52 UTC