- From: Mattias Buelens <notifications@github.com>
- Date: Wed, 21 Sep 2022 01:51:55 -0700
- To: whatwg/fetch <fetch@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Wednesday, 21 September 2022 08:52:08 UTC
This is intended behavior: * `response.body` always returns the same `ReadableStream`. * Async-iterating a `ReadableStream` all the way to the end (as with `for await`) leaves it unlocked and in the "closed" state. * Async-iterating an unlocked closed `ReadableStream` is allowed, although the iteration ends immediately. I agree that the combination of these behaviors like in your example leads to a bit of a surprising result. But I also don't see a way to fix this... 😕 In hindsight, I would have preferred Fetch to have a `Response.stream()` method instead of a `Response.body` property, similar to [`Blob.stream()`](https://w3c.github.io/FileAPI/#stream-method-algo) (see https://github.com/whatwg/streams/issues/1105#issuecomment-771210640). Then it would be immediately obvious that calling `stream()` twice should throw an "already used" error. But I guess that ship has sailed? -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/fetch/issues/1488#issuecomment-1253401483 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/fetch/issues/1488/1253401483@github.com>
Received on Wednesday, 21 September 2022 08:52:08 UTC