v159 · networking · webtransport
WebTransportError API alignment and serialization
Chromium’s WebTransportError predates the spec it implements. It only accepted a dictionary (new WebTransportError({message, streamErrorCode})), squeezed the stream error code into 8 bits even though the attribute is an unsigned long, and threw DataCloneError the moment you tried to postMessage one out of a worker. Chrome 159 adds the standard new WebTransportError(message, {source, streamErrorCode}) constructor, carries the full 32-bit code, and makes the error structured-clonable — while keeping the old dictionary constructor working.
How to run it. Enabled by default from Chrome 159; Firefox and Safari already ship the standard shape. In a developer-trial build, turn on chrome://flags/#enable-experimental-web-platform-features. Serialization has its own writer-side runtime switch, WebTransportErrorSerialization (status “stable” in Chromium’s runtime_enabled_features.json5); if a build has it switched off, relaunch with --enable-blink-features=WebTransportErrorSerialization. The new constructor has no flag of its own. Everything here runs without a WebTransport server — the network errors come from a real session attempt against an address that is guaranteed to refuse it.
concepts
-
Constructor overloads
Build an error with the standard
(message, options)shape or the legacy dictionary shape, read backname,code,sourceandstreamErrorCode, then run a matrix of call shapes — strings, dictionaries,undefined,null, an invalidsource— to see which overload WebIDL picks. -
Stream error code range
An inspection tool for the code itself: type any number and compare what the standard
[Clamp] unsigned longkeeps with what the legacy[Clamp] octetkeeps, then see the HTTP/3 error codepoint the spec maps that code to on the wire. -
Worker error relay
The everyday reason serialization matters: networking lives in a Worker, the UI lives in the page. A real failed session inside a Worker rejects with a
WebTransportError, and the Worker posts that error object straight to the page — or reports theDataCloneErrorthat pre-159 builds throw. -
Persisted error log
IndexedDB stores values by structured serialization, so a 159 build can keep real
WebTransportErrorobjects in a diagnostics log and read them back after a reload. See exactly which fields survive the trip — and thatstackdeliberately does not. -
Migration shim
Code that must run on both sides of the change: two independent probes (constructor, serialization), a constructor helper that reports when it had to fall back to the 8-bit legacy path, and a clone helper that ships a plain record only when the browser cannot clone the error itself.
why it shipped
The interface in the WebTransport spec gained a (message, options) constructor so that a WebTransportError can be built like any other DOMException, with an explicit source ("stream" or "session"). Chromium kept its older dictionary-only constructor, so portable code that worked in Firefox and Safari threw TypeError in Chrome. The stream error code is an application protocol value carried in RESET_STREAM and STOP_SENDING; the protocol allows 32 bits, but Chromium narrowed outgoing codes to 8 bits. And because the spec marks the interface [Serializable], an error raised in a worker or stored in IndexedDB should keep its source and streamErrorCode — Chromium refused to clone it at all. All three gaps showed up in the Interop 2026 WebTransport proposal.
the API
// Standard constructor (Chrome 159, Firefox, Safari)
const err = new WebTransportError("peer reset", {
source: "stream", // or "session"; default "stream"
streamErrorCode: 70000, // [Clamp] unsigned long?, default null
});
err.name; // "WebTransportError"
err.code; // 0 — no legacy DOMException code
err.streamErrorCode; // 70000
// Legacy constructor — still accepted by Chromium for compatibility
new WebTransportError({ message: "peer reset", streamErrorCode: 300 });
// → source "stream", streamErrorCode clamped to 255 ([Clamp] octet)
// Serialization: message, source and streamErrorCode survive
const copy = structuredClone(err);
copy instanceof WebTransportError; // true
worker.postMessage(err); // no more DataCloneError
writer.abort(err); // sends the full 32-bit code in RESET_STREAM
references
- ChromeStatus entry
- WebTransport spec §12 — WebTransportError interface (constructor, attributes, serialization)
- WebTransport spec §13 — protocol mappings for abort / cancel error codes
- draft-ietf-webtrans-http3 §4.4 — mapping application codes to HTTP/3 error codes
- WebTransport explainer
- issues.chromium.org/577073049 — implementation tracking
- Chromium: web_transport_error.idl (both constructors)
- MDN: WebTransportError
- Chrome for Developers: Using WebTransport
- Firefox bug 2009530 · WebKit bug 305224