v160 · webtransport · getStats() · datagrams
Datagram loss lab: which knob dropped my datagrams?
Datagrams are unreliable by design, so "some went missing" is expected — the question is where. stats.datagrams splits the loss into four causes: the receive queue overflowed because the page read too slowly (droppedIncoming), a received datagram aged past incomingMaxAge (expiredIncoming), a queued outgoing datagram aged past outgoingMaxAge before it could be sent (expiredOutgoing), or the network lost it (lostOutgoing). Set the knobs, fire a burst at an echo server, and read the before/after delta.
Availability. Chrome 160 ships WebTransport.prototype.getStats() enabled by default — the Blink runtime feature WebTransportStats is status: "stable" in runtime_enabled_features.json5. On an older Chrome the method is absent: enable chrome://flags/#enable-experimental-web-platform-features and relaunch, or launch with --enable-blink-features=WebTransportStats (both verified on Chrome 153). Real numbers also need a WebTransport server you can reach: this showcase has no HTTP/3 server of its own, so the default endpoint is a public echo server. If your network blocks QUIC the attempt fails with the real error, shown verbatim — never a made-up result. Running your own server is a few lines; see the local echo server recipe.
Run a burst
| counter | before | after | delta | what increments it |
|---|
reading the result honestly
- An echo server bounces the burst straight back. With reading off and a small
incomingHighWaterMark, the receive queue fills and everything past it isdroppedIncoming— that is the page's fault, not the network's. expiredIncomingneeds both a setincomingMaxAgeand datagrams that sit unread past it. Chromium applies the queue limits when you callgetStats(), so the count is current at snapshot time.expiredOutgoingonly moves if the sender is congestion-limited for longer thanoutgoingMaxAge— on a fast local link it often stays 0. That is a real result, not a failure of the demo.lostOutgoingreflects real QUIC loss detection. Zero on a clean path is the expected reading.- A counter shown as absent is one this browser did not include in the dictionary. On Chrome 153 (flagged)
expiredIncomingwas absent in every result we took, even withincomingMaxAgeset — re-check on Chrome 160.
code path
transport.datagrams.incomingHighWaterMark = 4;
transport.datagrams.incomingMaxAge = 50; // ms, or null
const before = (await transport.getStats()).datagrams;
const w = transport.datagrams.writable.getWriter();
for (let i = 0; i < 200; i++) await w.write(payload);
await sleep(1000);
const after = (await transport.getStats()).datagrams;
after.droppedIncoming - before.droppedIncoming; // overflowed the receive queue