Skip to content

Add byte stream bounds to WebTransport stream types - #2596

Open
Martin Ferret (MartinFerret) wants to merge 1 commit into
microsoft:mainfrom
MartinFerret:fix-2439-webtransport-stream-types
Open

Martin Ferret (MartinFerret) wants to merge 1 commit into
microsoft:mainfrom
MartinFerret:fix-2439-webtransport-stream-types

Conversation

@MartinFerret

Copy link
Copy Markdown
Contributor

Fixes #2439

WebTransportReceiveStream, WebTransportSendStream and WebTransportDatagramsWritable extended plain ReadableStream / WritableStream, so their chunks were any: reading gave you any, and you could write anything, even a string.

I gave them proper bounds:

  • WebTransportReceiveStream extends ReadableStream<Uint8Array<ArrayBuffer>>
  • WebTransportSendStream extends WritableStream<BufferSource>
  • WebTransportDatagramsWritable extends WritableStream<BufferSource>

This matches how byte streams are already typed in lib.dom (Response.body for reading, CompressionStream.writable for writing), and the WebTransport spec, which rejects any chunk that isn't a BufferSource, for send streams and for datagrams.

The change is a few lines in inputfiles/patches/webtransport.kdl, with regenerated baselines. I also added unittests/files/webtransport.ts: it checks the chunk types, that a string can't be written anymore, and that all three are still assignable to ReadableStream / WritableStream. It fails without the patch.

One thing I noticed: a few related properties in the same patch file still use plain streams (WebTransportBidirectionalStream.readable / .writable, the return type of createUnidirectionalStream(), and WebTransportDatagramDuplexStream.writable), so chunks there are still any. I can update them here or in a follow-up, whichever you prefer.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the PR!

This section of the codebase is owned by Kagami Sascha Rosylight (@saschanaz) - if they write a comment saying "LGTM" then it will be merged.

@saschanaz

Copy link
Copy Markdown
Contributor

Looks reasonable, thanks!

@MartinFerret

Copy link
Copy Markdown
Contributor Author

Thanks! You think I should fix the related properties in a follow-up PR?

@saschanaz

Copy link
Copy Markdown
Contributor

LGTM

@saschanaz

Copy link
Copy Markdown
Contributor

Thanks! You think I should fix the related properties in a follow-up PR?

SGTM

@github-actions

Copy link
Copy Markdown
Contributor

Sorry Kagami Sascha Rosylight (@saschanaz), this PR has merge conflicts. They'll need to be fixed before this can be merged.

@MartinFerret
Martin Ferret (MartinFerret) force-pushed the fix-2439-webtransport-stream-types branch from 3423f1f to 0996d5d Compare November 11, 2026 07:58
@MartinFerret

Copy link
Copy Markdown
Contributor Author

Rebased on main, the conflicts are now fixed. Could you take another look when you have a minute? Thanks!

@MartinFerret
Martin Ferret (MartinFerret) force-pushed the fix-2439-webtransport-stream-types branch from 0996d5d to 446af8d Compare November 12, 2026 14:43
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.

[Web API type definition issue] Missed bounds in WebTransportReceiveStream, WebTransportSendStream and WebTransportDatagramsWritable parent types

2 participants