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

Confirmed, I can get the reference implementation to throw an `AssertionError` with your test:
```javascript
promise_test(async () => {
  const rs = new ReadableStream({
    type: 'bytes',
    autoAllocateChunkSize: 10,
    pull(c) {
      c.enqueue(new Uint8Array(10));
      c.byobRequest.respond(10);
    }
  });

  const reader = rs.getReader();

  console.log(await reader.read());
  console.log(await reader.read());

  console.log('test');
}, '#1170');
```
(I did need to call `read()` twice though.)

Things start to go wrong immediately in [ReadableByteStreamControllerEnqueue](https://streams.spec.whatwg.org/commit-snapshots/8bbfbf83ad06a8b9224bbe1cfbcbbbdbdd827a19/#readable-byte-stream-controller-enqueue). We end up in step 10.2, where we fulfill the `read()` request *but we do not remove the auto-allocated pull-into descriptor*. Probably because we assumed that there wouldn't be any that need to be removed, which turns out to be wrong. Woops! 😛

This is definitely a spec bug. Thanks for reporting! 😁

-- 
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-933805243

Received on Monday, 4 October 2021 19:54:08 UTC