Re: [whatwg/streams] `.throw()`ing an async iterator (Issue #1284)

```js
const r = new ReadableStream({
  pull(c) {
    c.enqueue("hello");
  },
  cancel(arg) {
    console.log("cancel", arg);
  }
})
for await (const chunk of r) {
  throw new Error("errored!");
}
```

This indeed doesn't seem to pass the error object to the cancel callback, `arg` is undefined in this case.

I guess a blocking issue is that Web IDL does not define the hook for `throw`: https://webidl.spec.whatwg.org/#idl-async-iterable

>We could add a similar hook for throw(). So far there has been no need, but if you are creating an API that needs such capabilities, please [file an issue](https://github.com/whatwg/webidl/issues/new?title=Enhancement%20request%20for%20Async%20Iterables).

Should we have an issue? @MattiasBuelens 

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/1284#issuecomment-1598655851
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/streams/issues/1284/1598655851@github.com>

Received on Tuesday, 20 June 2023 12:11:32 UTC