WebTransport datagrams.readable is never closed or errored when the session closes
Categories
(Core :: DOM: Networking, defect, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox163 | --- | fixed |
People
(Reporter: jesup, Assigned: jesup)
References
(Depends on 1 open bug)
Details
(Whiteboard: [necko-triaged], [wptsync upstream])
Attachments
(2 external files)
When a WebTransport session is cleaned up (close(), a remote close, or a failure), WebTransport::Cleanup() never closes or errors transport.datagrams.readable. A pending datagrams.readable read never resolves with done: true after a clean close, and is never rejected after a failure; a pull waiting on the incoming datagrams algorithm is left unsettled too.
The cleanup algorithm (https://w3c.github.io/webtransport/#webtransport-cleanup) also has several other datagram steps that Firefox doesn't follow:
- Step 13 (empty
[[IncomingDatagramsQueue]]) is missing, so datagrams buffered before the close can still be read afterwards. - Step 11 (empty
[[Datagrams]].[[Writables]]) is missing; the transport keeps every writable fromcreateWritable()after cleanup. - Steps 11-13 run at the very end of
Cleanup(), afterclosedhas settled and the incoming streams have closed, instead of before the state changes in step 14. Resolvingclosedcan run script synchronously (through athengetter), so the datagram queues are emptied after script could have touched them, and the backpressure promises resolve afterclosed's reactions instead of before. - Steps 17.6 / 18.8 (close or error
incomingDatagrams) are missing, as above.
Two comments are stale: the TODO above the datagram cleanup in WebTransport::Cleanup() says the spec doesn't resolve withheld write promises, but w3c/webtransport#790 (merged 2026-10-19) added that as step 12.2; and WebTransportDatagramDuplexStream::CloseOrErrorWritable() cites cleanup step 16.5, which is now 17.5.
Steps to reproduce:
- Connect a WebTransport and call
wt.datagrams.readable.getReader().read()without any datagrams arriving. - Call
wt.close().
Expected: the read resolves with done: true, and reader.closed resolves.
Actual: the read stays pending forever.
The same happens after a failure, where the read should be rejected with the cleanup error.
Testcase: webtransport/datagrams-cleanup.https.any.js.
| Assignee | ||
Comment 1•1 month ago
|
||
WebTransport::Cleanup() never closed or errored the incoming datagrams
readable (cleanup steps 17.6/18.8), never emptied
[[IncomingDatagramsQueue]] (step 13) or [[Writables]] (step 11), and
ran the remaining datagram steps after closed had settled. Steps 11-13
now run before step 14, the writables and readable are settled in steps
17.5-17.6/18.7-18.8, and datagrams arriving after cleanup are dropped.
| Assignee | ||
Comment 2•1 month ago
|
||
w3c/webtransport#790 replaced the per-datagram write promise with a single
[[BackpressurePromise]] per datagrams writable, resolved by "dequeue
outgoing datagrams" and by cleanup. Since WritableStream only calls the
sink's write once the previous write's promise has settled, the FIFO of
withheld write promises never held more than one, so replace it with that
slot. The pre-connect queue no longer carries promises either.
Requote the writeDatagrams, sendDatagrams, dequeue outgoing datagrams and
datagrams writable create steps against the current spec.
Comment 6•8 days ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/1ca0a2859447
https://hg.mozilla.org/mozilla-central/rev/f84c6986c0b9
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/65567 for changes under testing/web-platform/tests
Upstream PR merged by moz-wptsync-bot
Description
•