Closed Bug 2084216 Opened 1 month ago Closed 26 days ago

Failed WebTransport sessions report unhandled promise rejections for `closed` and `ready`

Categories

(Core :: DOM: Networking, defect, P3)

defect

Tracking

()

RESOLVED FIXED
162 Branch
Tracking Status
firefox162 --- fixed

People

(Reporter: tschuster, Assigned: jesup)

References

(Blocks 1 open bug)

Details

(Whiteboard: [necko-triaged])

Attachments

(1 external file)

When a WebTransport session fails (for example, the server rejects the connection), Firefox rejects transport.closed and transport.ready without marking them as handled. A page that never attaches a handler to closed therefore gets an "Unhandled rejection" for every failed session.

The spec says these rejections must be marked as handled. The last step of the WebTransport "cleanup" algorithm (https://w3c.github.io/webtransport/#webtransport-cleanup) reads, for the case without closeInfo:

Otherwise:

  1. Reject closed with error.
  2. Set closed.[[PromiseIsHandled]] to true.
  3. Reject ready with error.
  4. Set ready.[[PromiseIsHandled]] to true.
  5. Error incomingBidirectionalStreams with error.

In WebTransport::Cleanup (dom/webtransport/api/WebTransport.cpp), the failure branch implements the rejections but skips both [[PromiseIsHandled]] steps:

https://searchfox.org/firefox-main/rev/fc216bdbdf04fca964b8f241844b0e6d048cc245/dom/webtransport/api/WebTransport.cpp#1537

    // 13.1: Reject closed with error
    mClosed->MaybeReject(errorValue);
    // 13.2: Reject ready with error
    mReady->MaybeReject(errorValue);

These are the only places mClosed and mReady are rejected. Every failed session goes through them, including a refused connection: RejectWaitingConnection builds the "WebTransport connection rejected" error and calls Cleanup(error, nullptr, ...).

Suggested fix: call SetSettledPromiseIsHandled() on mClosed and mReady right after rejecting them. The step-number comments in Cleanup no longer match the spec, which has since added steps for datagrams, so they should be updated at the same time.

Test impact: connection-allowlist/tentative/webtransport-document.https.sub.window.js currently ends in a harness ERROR ("Unhandled rejection: WebTransport connection rejected"). Its WebTransport attempts are expected to fail, and it never handles closed. This hides all of its subtest results. https://tests.firefox.dev/test.html?test=testing/web-platform/tests/connection-allowlist/tentative/webtransport-document.https.sub.window.js

Assignee: nobody → rjesup
Severity: -- → S3
Priority: -- → P3
Whiteboard: [necko-triaged]

Also renumber the cleanup step comments to match the current spec, and drop
the harness ERROR expectations the unhandled rejections caused.

See Also: → 2085562
See Also: → 2085588

Thanks for working on this. Is this ready to land?

Flags: needinfo?(rjesup)

There is an r+ patch which didn't land and no activity in this bug for 1 week.
:jesup, could you have a look please?
If you still have some work to do, you can add an action "Plan Changes" in Phabricator.
For more information, please visit BugBot documentation.

Flags: needinfo?(rjesup)
Pushed by rjesup@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/5733912a00c7 https://hg.mozilla.org/integration/autoland/rev/a86731bbb851 mark a failed WebTransport's rejected closed and ready promises as handled r=jib
Flags: needinfo?(rjesup)
Status: NEW → RESOLVED
Closed: 26 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch
QA Whiteboard: [qa-triage-done-c163/b162]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: