Re: [whatwg/streams] Various fixes for readable byte streams (#1123)

> Given the limited use case of `respondWithNewView()` and large number of ways to get it wrong, could we just eliminate it?

Not really. Although the use cases are rare, they *are* important:
* To tee a readable byte stream (#1114), we want to use the BYOB request from a branch to perform a BYOB read on the original stream. That `read(view)` call *always* transfers the given buffer, so the branch's BYOB request becomes detached. The only way to get the result from `read(view)` back into the branch is [by calling `respondWithNewView()`](https://github.com/whatwg/streams/blob/8aa13163a1cfaf1d8be0070e505ef15aa418a806/reference-implementation/lib/abstract-ops/readable-streams.js#L565). (We *could* [implement teeing without using a BYOB reader](https://github.com/whatwg/streams/blob/8aa13163a1cfaf1d8be0070e505ef15aa418a806/reference-implementation/lib/abstract-ops/readable-streams.js#L484), but that kind of defeats the point of using a readable byte stream over a "regular" readable stream with `Uint8Array` chunks...)
* If we ever want to make readable byte streams transferable *without copying chunks around*, we will *need* the ability to transfer BYOB requests between realms. This won't be for any time soon though: transferable streams are currently implemented as pipes between cross-realm readable/writable streams, and we don't have "writable byte streams" yet (#495).

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

Received on Monday, 17 May 2021 09:52:37 UTC