WebTransport incomingBidirectionalStreams can return a usable-looking stream after the transport is closed
Categories
(Core :: DOM: Networking, defect, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox163 | --- | fixed |
People
(Reporter: jesup, Assigned: jesup, NeedInfo)
References
Details
(Whiteboard: [necko-triaged], [wptsync upstream])
Attachments
(1 external file)
When a WebTransport session closes cleanly, WebTransport::Cleanup() resolves closed with a WebTransportCloseInfo object. Resolving a promise with an object looks up then on it synchronously, so a getter on Object.prototype.then runs in the middle of cleanup, after [[SendStreams]]/[[ReceiveStreams]] have been emptied and errored but before incomingBidirectionalStreams/incomingUnidirectionalStreams are closed.
If that getter calls read() on an incoming streams reader while the server has opened streams the page hasn't pulled yet, the pull algorithm runs synchronously. WebTransportIncomingStreamsAlgorithms::BuildStream takes the next queued pipe, creates a new WebTransportBidirectionalStream (or WebTransportReceiveStream), adds it to the transport's stream sets after they were already errored, and enqueues it. The page gets a stream on a closed transport that is never errored; it only dies when its underlying pipes are torn down.
Per spec, pulling after cleanup has no session to receive a stream from, and the incoming streams are then closed, so the read should resolve with done: true.
Steps to reproduce:
- Connect to a server that opens several bidirectional streams, then a unidirectional stream as a marker.
- Read the marker from
incomingUnidirectionalStreams; the bidirectional streams are now queued but not pulled. - Get a reader for
incomingBidirectionalStreamswithout reading from it, and define athengetter onObject.prototypethat, when called on the close info object, callsreader.read()on that reader. - Call
wt.close()and await the read.
Expected: the read resolves with done: true.
Actual: the read resolves with a new bidirectional stream.
The fix is to implement step 2 of pullBidirectionalStream/pullUnidirectionalStream (reject the pull once the transport is closed or failed), and have BuildStream bail out for a waiting pull that resumes after cleanup. Testcase: webtransport/close2.https.any.js.
| Assignee | ||
Comment 1•1 month ago
|
||
A 'then' getter on Object.prototype runs synchronously while Cleanup()
resolves closed, and can read from an incoming streams readable. The
pull then built a stream from a queued pipe and added it to the
transport's stream sets after they had already been errored, handing
script a live-looking stream on a closed transport.
Implement step 2 of pullBidirectionalStream/pullUnidirectionalStream,
rejecting the pull once the transport is closed or failed, and have
BuildStream bail out too for a waiting pull that resumes after cleanup.
Updated•1 month ago
|
| Assignee | ||
Updated•1 month ago
|
Comment 4•14 days ago
|
||
Backed out for causing bustages complaining about wt_initial_max_data.
Backout link: https://hg.mozilla.org/integration/autoland/rev/f6b8b56f1d93
Push with failures: https://treeherder.mozilla.org/jobs?repo=autoland&resultStatus=testfailed%2Cbusted%2Cexception%2Cretry%2Cusercancel&revision=addcc940dd4ff68a71837a1086d5641e791a99d8
Comment 6•13 days ago
|
||
| bugherder | ||
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/65566 for changes under testing/web-platform/tests
Upstream PR merged by moz-wptsync-bot
Description
•