Skip to content

Omit empty datagrams with a BYOB reader instead of erroring the stream - #800

Open
jan-ivar wants to merge 1 commit into
w3c:mainfrom
jan-ivar:empty-byob-datagram
Open

jan-ivar wants to merge 1 commit into
w3c:mainfrom
jan-ivar:empty-byob-datagram

Conversation

@jan-ivar

@jan-ivar jan-ivar commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Fixes #795.

With datagramsReadableType: "bytes" and a pending BYOB read, a zero-length datagram made pull from bytes call ReadableByteStreamControllerRespond(0), which throws and errors datagrams.readable.

This takes option 1 from the issue: pullDatagrams skips empty datagrams when a BYOB request is pending, and pulls the next one. The BYOB request stays pending until a non-empty datagram arrives.

It also corrects the note: only a BYOB reader omits empty datagrams. A default reader still gets an empty chunk.


Preview | Diff

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pullDatagrams errors datagrams.readable on a zero-length datagram when datagramsReadableType is "bytes"

1 participant