Repository navigation
Fix respond() leaving bytes queued behind a pending read() - #1393
Open
MattiasBuelens wants to merge 1 commit into
Open
MattiasBuelens wants to merge 1 commit into
MattiasBuelens wants to merge 1 commit into
Conversation
ReadableByteStreamControllerRespondInReadableState() moves the bytes written into a detached pull-into descriptor to the queue, and then fills any pending pull-into descriptors from it. Nothing fills pending read requests, so a default reader with no autoAllocateChunkSize has no descriptor to absorb the bytes and its read() never settles, even though the bytes it needs are sitting in the queue. Process the read requests as well, after the pull-into descriptors. Doing it in that order keeps the auto-allocated descriptor of a default reader in play: with autoAllocateChunkSize the queued bytes are copied into that descriptor, so the chunk is still backed by the buffer that was allocated for that read(), and the queue is drained before the read requests are considered. Fixes whatwg#1390.
shannonbooth
approved these changes
Oct 25, 2026
shannonbooth
left a comment
Member
There was a problem hiding this comment.
spec change and test looks good to me, hopefully implementors express interest!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ReadableByteStreamControllerRespondInReadableState()moves the bytes written into a detached pull-into descriptor to the queue, and then fills any pending pull-into descriptors from it. However, we also need to fill any pendingread()requests, since a default reader doesn't have a pull-into descriptor when there's noautoAllocateChunkSize. This left theread()pending forever, even though the stream does have bytes for it in its queue.Fix it by also processing the read requests in this scenario, after processing the pull-into descriptors (so with
autoAllocateChunkSize, the queued bytes still go into the buffer allocated for thatread()).Fixes #1390.
respond()on a detached pull-into descriptor web-platform-tests/wpt#64195(See WHATWG Working Mode: Changes for more details.)
Preview | Diff