Re: [whatwg/streams] Proposal: ReadableStreamBodyReader (Issue #1238)

Making this a proper reader can also have weird consequences. What should happen if you call `releaseLock()` while `arrayBuffer()` is still pending, and then you acquire a new reader?

```javascript
const stream = new ReadableStream({ type: "bytes" });
const reader1 = stream.getReader({ mode: "body" });
reader1.arrayBuffer().catch(() => {});
// ...some time passes
reader1.releaseLock();
const reader2 = stream.getReader();
await reader2.read(); // what does this return?
```
Will `reader2` see the full contents of `stream`? Or will `reader1` have already consumed some bytes, such that `reader2` only sees the remaining bytes?

It's also a bit weird conceptually: the `Body` mixin is defined on top of `ReadableStream`, but now you'd be able to consume a `ReadableStream` as a `Body` too? It's unclear which of the two is the "base primitive". 😛

We already proposed the idea of adding something like `ReadableStream.prototype.arrayBuffer()` in https://github.com/whatwg/streams/issues/1019. I think that's a better starting point, and then `response.arrayBuffer()` could become a shorthand for `response.body.arrayBuffer()`. 🙂

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/1238#issuecomment-1175575671

You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/streams/issues/1238/1175575671@github.com>

Received on Tuesday, 5 July 2022 22:46:12 UTC