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

WebTransport endpoint

Any WebTransport server you can reach — a public echo server by default, or your own local one.

For a local self-signed server (ECDSA, ≤14-day cert). Leave empty for a publicly trusted certificate.

Not run yet. Try it twice: once with reading off (expect droppedIncoming), once with it on.
stats.datagrams — before vs after the burst
counterbeforeafterdeltawhat increments it

reading the result honestly

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

see also