[whatwg/streams] Default read hangs after BYOB releaseLock() and respond() (Issue #1390)

shannonbooth created an issue (whatwg/streams#1390)

### What is the issue with the Streams Standard?

If a BYOB reader is released with a partially filled pull-into, the pull-into stays pending with reader type “none” (from #1170). A default reader acquired afterwards can then have a read request pending behind it:

```js
let controller;
const stream = new ReadableStream({ type: "bytes", start(c) { controller = c; } });

const byobReader = stream.getReader({ mode: "byob" });
byobReader.read(new Uint16Array(1));
await new Promise(r => setTimeout(r));
controller.byobRequest.view[0] = 0xaa;
controller.byobRequest.respond(1);   // 1 of 2 bytes filled, pull-into stays pending
byobReader.releaseLock();            // reader type becomes "none"

const reader = stream.getReader();
const read1 = reader.read();         // queue is empty, so the read request is pending
await new Promise(r => setTimeout(r));
controller.byobRequest.view[0] = 0xbb;
controller.byobRequest.respond(1);   // bytes are queued, but read1 is never fulfilled
const read2 = reader.read();         // assertion failure
```

When the source finishes the pull-into with respond(), [ReadableByteStreamControllerRespondInReadableState](https://streams.spec.whatwg.org/#readable-byte-stream-controller-respond-in-readable-state) moves the bytes into the queue but doesn’t fulfill any pending read requests:

```
If pullIntoDescriptor’s reader type is “none”,
Perform ? ReadableByteStreamControllerEnqueueDetachedPullIntoToQueue(controller, pullIntoDescriptor).
Let filledPullIntos be the result of performing ! ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller).
...
Return.
```

So read1 stays pending even though there are bytes in the queue. The next read() then reaches [[[PullSteps]]](https://streams.spec.whatwg.org/#rbs-controller-private-pull) with a non-empty queue and fails:

```
If this.[[queueTotalSize]] > 0,
Assert: ! ReadableStreamGetNumReadRequests(stream) is 0.
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/1390
You are receiving this because you are subscribed to this thread.

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

Received on Saturday, 24 October 2026 21:18:11 UTC