Open Bug 2085220 Opened 1 month ago Updated 1 month ago

WebTransport: datagrams.maxDatagramSize stays 0 forever when the session is closed right after establishment

Categories

(Core :: Networking, defect, P3)

x86_64
Linux
defect

Tracking

()

ASSIGNED

People

(Reporter: jeon1691, Assigned: jesup, NeedInfo)

Details

(Whiteboard: [necko-triaged])

Filed per rjesup's request on bug 2084924 (dup of bug 1818883): "~45 WebTransport patches landed in the last week; the main issues here all appear to be resolved. Retest, if there are still issues please file new bugs."

Retested both issues from 2084924 on current Nightly with the same harness. The datagram write() hang is FIXED. This bug is the surviving residual: datagrams.maxDatagramSize stays 0 forever when the session is closed immediately after establishment.

User impact: when a WebTransport session is closed by the server right after establishment, wt.datagrams.maxDatagramSize keeps its initial value 0 forever, even though wt.ready and wt.closed both settle cleanly. A page that sizes or gates its datagrams on maxDatagramSize (a common pattern, since datagrams larger than maxDatagramSize cannot be sent) sees 0 and must treat the datagram feature as unusable for that session object.

Retest numbers (same harness as bug 2084924: local aioquic WPT WebTransport server + serverCertificateHashes; a handler that closes the session right at establishment):

Nightly 161.0a1, BuildID 20261022214940, changeset bbbd29a03fc7, neqo-http3 0.33.0 (Linux x86_64, network.webtransport.enabled=true):

  • 6/6 rounds: ready resolves, closed resolves cleanly (clean server close), maxDatagramSize == 0 immediately after ready AND 1200 ms later. It never updates.
  • Healthy-session baseline on the same build: maxDatagramSize = 1224 at ready, stable.
  • Control on the original-report build (160.0a1, BuildID 20261019073400, changeset 0fdb388b): identical 6/6 rounds stuck at 0, i.e. this half of 2084924 did not change with the patch wave.
  • For contrast, the write() hang half of 2084924 on 161 is fixed: server closes mid-cadence, sent=229, resolved=98, rejected=131, hung=0 (rechecked +17 s: still 0 hung); the old build still hangs 124/220 writes forever.

Source chain at bbbd29a03fc7:

  1. The child sets the duplex's max datagram size ONLY from the CreateWebTransportParent response tuple:
    dom/webtransport/api/WebTransport.cpp:521-525 - SetMaxDatagramSize(std::get<2>(aResult.ResolveValue())).

  2. The clean-close handler explicitly acknowledges this race and works around it for ready only - leaving the datagrams duplex at 0:
    dom/webtransport/api/WebTransport.cpp:1519-1523 (step 12.2):
    // 12.2: Assert: ready is settled.
    // However, if the connection closes before maxDatagramSize is received,
    // ready may still be pending. Resolve it in that case.
    if (mReady->State() == Promise::PromiseState::Pending) {
    mReady->MaybeResolveWithUndefined();
    }
    There is no corresponding size delivery for the datagrams duplex on this path, so the attribute keeps its initial 0 value permanently.

  3. Parent side, the value is fetched at session-ready and forwarded to the child only if the session has not already closed:
    dom/webtransport/parent/WebTransportParent.cpp:724-743 - OnSessionReady fetches GetMaxDatagramSize() into mMaxDatagramSizeValue and forwards it via CallResolver(..., maxDatagramSize), but the dispatch is gated by if (!self->mClosed && self->mResolver) - on an immediate close the value never reaches the child.

  4. The RecvGetMaxDatagramSize IPC fallback still drops its resolver on closed sessions (the same shape 2084924 described for OutgoingDatagram, whose write-side sibling is now fixed):
    dom/webtransport/parent/WebTransportParent.cpp:1084-1096 - stores mMaxDatagramSizeResolver, calls mWebTransport->GetMaxDatagramSize() with the return value ignored;
    netwerk/protocol/webtransport/WebTransportSessionProxy.cpp:821-842 - returns NS_ERROR_NOT_AVAILABLE when mState != ACTIVE, without invoking the callback;
    dom/webtransport/parent/WebTransportParent.cpp:1218-1228 - OnMaxDatagramSize is the only place the resolver is settled; if the callback never fires, the resolver is never settled.
    No session-close path (RecvClose / OnSessionClosed / ActorDestroy) settles or clears mMaxDatagramSizeResolver - in contrast, GetStats resolvers ARE settled on close (ResolvePendingGetStats).

Suggested fix directions:

  • On session-close paths, settle a pending mMaxDatagramSizeResolver (e.g. with the cached mMaxDatagramSizeValue), mirroring ResolvePendingGetStats; and/or
  • In the child's clean-close handler (the step 12.2 site), deliver a cached/fallback size to the datagrams duplex when ready was force-resolved without one, or define the post-close value explicitly.

Steps to reproduce (runtime-verified 6/6 on 161.0a1 BuildID 20261022214940):

Setup: local HTTP/3 WebTransport server (aioquic-based WPT tools/webtransport server, additionally advertising SETTINGS_ENABLE_WEB_TRANSPORT 0x2b603742 which current nightly requires from the server) with an ECDSA localhost cert accepted via the serverCertificateHashes option, and a handler that closes the session at establishment.

const wt = new WebTransport("https://127.0.0.1:4433/close_immediately", {serverCertificateHashes:[...]});
await wt.ready; // resolves
await wt.closed; // resolves (clean server close)
wt.datagrams.maxDatagramSize // == 0, immediately, +1.2 s, and forever
// healthy session on the same server: 1224

(MOZ_LOG=WebTransport:5 shows the session establishing and closing cleanly; the duplex never receives a size.)

Assignee: nobody → rjesup
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Flags: needinfo?(rjesup)
Priority: -- → P3
Whiteboard: [necko-triaged]
You need to log in before you can comment on or make changes to this bug.