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

Take the following test case, where there are multiple concurrent reads on a BYOB reader, where the controller is closed after the first pull, resolving the first read. Unfortunately, it seems the second read never gets resolved. Tested in Node.js and in Chrome.

```js
import { ReadableStream } from 'stream/web';

const rs = new ReadableStream({
  type: 'bytes',
  pull(c) {
    c.byobRequest.respond(10);
    c.close();
  }
});

const reader = rs.getReader({ mode: 'byob' });

console.log("....a");

const results = await Promise.all([
  reader.read(new Uint8Array(10)),
  reader.read(new Uint8Array(10)),
]);

console.log("....b");
```

![image](https://user-images.githubusercontent.com/439929/135887101-792eba3f-057d-4b92-8f1c-a839df9b1388.png)

When the reads are invoked sequentially and awaited separately it works as expected. When the concurrent reads are both pending, however, closing the controller will never resolve the second read.

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

Received on Monday, 4 October 2021 16:17:57 UTC