Repository navigation
Add byte stream bounds to WebTransport stream types - #2596
Jake Bailey (jakebailey) merged 2 commits into
Conversation
|
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. |
|
Looks reasonable, thanks! |
|
Thanks! You think I should fix the related properties in a follow-up PR? |
|
LGTM |
SGTM |
|
Sorry Kagami Sascha Rosylight (@saschanaz), this PR has merge conflicts. They'll need to be fixed before this can be merged. |
3423f1f to
0996d5d
Compare
|
Rebased on main, the conflicts are now fixed. Could you take another look when you have a minute? Thanks! |
0996d5d to
446af8d
Compare
|
Kagami Sascha Rosylight (@saschanaz) the conflicts are fixed and all checks pass. Could you LGTM it again so the bot can merge it? Thanks! |
|
Found a bug here while double-checking before 7.1, and pushed a fix.
Checked with TS 5.5.4, 5.6.3 and 5.9.3: no errors, main output unchanged, npm test passes. |
Fixes #2439
WebTransportReceiveStream,WebTransportSendStreamandWebTransportDatagramsWritableextended plainReadableStream/WritableStream, so their chunks wereany: reading gave youany, 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.bodyfor reading,CompressionStream.writablefor writing), and the WebTransport spec, which rejects any chunk that isn't aBufferSource, for send streams and for datagrams.The change is a few lines in
inputfiles/patches/webtransport.kdl, with regenerated baselines. I also addedunittests/files/webtransport.ts: it checks the chunk types, that a string can't be written anymore, and that all three are still assignable toReadableStream/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 ofcreateUnidirectionalStream(), andWebTransportDatagramDuplexStream.writable), so chunks there are stillany. I can update them here or in a follow-up, whichever you prefer.