Re: [whatwg/streams] Possible spec bug with concurrent byob reads (#1170)

Keep in mind that BYOB request handling changed a lot in #1123, and Chrome has yet to implement this ([Chromium bug #1223565](https://crbug.com/1223565)). So you won't get the desired behavior from Chrome. `streams/web` and `web-streams-polyfill` should be up-to-date though, so those are valid test cases.

> The assumption here is that the pull algorithm is even _aware_ that there are additional concurrent read requests that it needs to respond to. I'm assuming the only way to do that is to `while(c.byobRequest !== null) {}`

No, you don't need a loop. After you `controller.close()`, you only need to respond to the *current* BYOB request. Afterwards, the stream immediately commits all other pull-into descriptors (through [ReadableByteStreamControllerRespondInClosedState](https://streams.spec.whatwg.org/commit-snapshots/8bbfbf83ad06a8b9224bbe1cfbcbbbdbdd827a19/#readable-byte-stream-controller-respond-in-closed-state)).

In other words, this will do:
```javascript
c.close();
c.byobRequest?.respond(0);
```

I'll have a closer look at your `autoAllocateChunkSize` case.

-- 
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/issues/1170#issuecomment-933761170

Received on Monday, 4 October 2021 18:53:39 UTC