← Chrome 159 reference · All APIs
v159 · webtransport · in developer trial (behind a flag)
WebTransportError API alignment and serialization
Aligns Chromium’s WebTransportError with the W3C WebTransport specification by adding the standard new WebTransportError(message, options) constructor (while keeping Chromium’s legacy dictionary-only overload for compatibility), propagating full 32-bit unsigned long streamErrorCode values end-to-end without 8-bit truncation, and making WebTransportError [Serializable] for structuredClone(), postMessage(), and IndexedDB.
In Chrome 159, this alignment is filed under In developer trial (Behind a flag); ChromeStatus 5158277221580800 targets shipping enabled by default in Chrome 160 (desktop, Android, Android WebView). To test in Chrome 159, enable chrome://flags/#enable-experimental-web-platform-features or launch Chrome with --enable-blink-features=WebTransportErrorSerialization. Once shipped, serialization writing remains controlled by the WebTransportErrorSerialization runtime kill switch while versioned decoding stays permanently enabled so persisted values remain readable.
at a glance
| Status in Chrome 159 | In developer trial (Behind a flag) in Chrome 159 (desktop, Android); shipping enabled by default targeted for Chrome 160 (desktop, Android, Android WebView) per the milestone=159 listing and ChromeStatus API record |
|---|---|
| Flag / kill switch | chrome://flags/#enable-experimental-web-platform-features or --enable-blink-features=WebTransportErrorSerialization (Finch / runtime feature WebTransportErrorSerialization in runtime_enabled_features.json5) |
| Specification | W3C WebTransport §12 WebTransportError Interface; Protocol Mapping (32-bit error code) |
| Intent | blink-dev Intent to Ship |
| Tracking bug | issues.chromium.org/577073049 |
| Web platform tests | webtransport/idlharness.https.sub.any.html; WPT PR #63842 |
| ChromeStatus | 5158277221580800 — WebTransportError API alignment and serialization |
why it exists
Chromium’s original WebTransportError implementation (shipped in Chrome 97) predated three changes in the W3C WebTransport specification: it only exposed a legacy dictionary constructor (new WebTransportError({ message, streamErrorCode })) instead of the DOMException-aligned (message, options) signature; it narrowed outgoing application stream error codes to 8 bits (0–255) even though the attribute type was unsigned long?; and it lacked structured serialization support, causing worker-to-window error relays and IndexedDB error logs to fail or drop WebTransport metadata. Aligning Chromium with Firefox and Safari closes these interop gaps without breaking existing callers that pass a dictionary as the first argument.
Syntax
Verbatim Blink WebIDL (matching W3C WebTransport §12 plus Chromium’s retained legacy compatibility overload):
// third_party/blink/renderer/modules/webtransport/web_transport_error.idl
enum WebTransportErrorSource {
"stream",
"session",
};
[Exposed=(Window,Worker), Serializable, SecureContext]
interface WebTransportError : DOMException {
// Standard W3C constructor
constructor(optional DOMString message = "",
optional WebTransportErrorOptions options = {});
// Chromium legacy compatibility overload (clamps streamErrorCode to octet 0..255)
[MeasureAs=WebTransportErrorLegacyConstructor]
constructor(WebTransportErrorInit init, optional any legacyIgnored);
readonly attribute unsigned long? streamErrorCode;
readonly attribute WebTransportErrorSource source;
};
// third_party/blink/renderer/modules/webtransport/web_transport_error_options.idl
dictionary WebTransportErrorOptions {
WebTransportErrorSource source = "stream";
[Clamp] unsigned long? streamErrorCode = null;
};
// third_party/blink/renderer/modules/webtransport/web_transport_error_init.idl
dictionary WebTransportErrorInit {
[Clamp] octet streamErrorCode;
DOMString message;
};
This reference documents four parts of the contract: standard (message, options) constructor, legacy dictionary overload, 32-bit streamErrorCode and source, and [Serializable] structured cloning.
Standard constructor: new WebTransportError(message, options)
Inputs. Accepts two optional parameters matching the W3C specification:
message(DOMString, default""): human-readable error description stored in the inheritedDOMException.messageattribute.options(WebTransportErrorOptions, default{}):source(WebTransportErrorSource, default"stream"): either"stream"or"session". Passing any other string throws aTypeErrorvia WebIDL enum conversion.streamErrorCode([Clamp] unsigned long?, defaultnull): nullable 32-bit unsigned integer (0to4294967295). Negative numbers clamp to0; values above4294967295clamp to4294967295;nullorundefinedkeeps the attributenull.
Outputs. Returns a WebTransportError instance (subclass of DOMException) with name === "WebTransportError", legacy code === 0, and the requested message, source, and streamErrorCode.
Legacy compatibility overload: new WebTransportError(init)
Inputs. When the first argument is a non-null JS object (matching WebIDL dictionary overload resolution for WebTransportErrorInit), Chromium dispatches to the retained legacy overload constructor(WebTransportErrorInit init, optional any legacyIgnored):
init.message(optionalDOMString, default""): copied intoerror.message.init.streamErrorCode(optional[Clamp] octet): clamped to0–255(if omitted,streamErrorCodeisnull).legacyIgnored(optionalany): ignored to preserve compatibility with existing callers that passed trailing arguments.
Outputs & migration note. Always produces source === "stream" and increments Chromium’s WebTransportErrorLegacyConstructor UseCounter. Firefox and Safari only implement the standard (message, options) signature — passing an object as the first argument there coerces it via ToString() to "[object Object]". New cross-browser code should always call new WebTransportError(message, options).
Full 32-bit streamErrorCode and source
Inputs & outputs. error.streamErrorCode is a read-only unsigned long? carrying the full 32-bit application stream error code (0 through 4294967295, or null when no application error code applies). Previously, Chromium truncated outgoing application stream error codes (for example when aborting a stream or calling ReadableStream.cancel() / WritableStream.abort() with a WebTransportError) to 8 bits (0–255). With this change, Chromium carries the full 32-bit uint32_t value end-to-end across HTTP/3 WebTransport stream reset/stop-sending protocol mapping. error.source is a read-only WebTransportErrorSource equal to "stream" (error originated on an individual stream or client abort) or "session" (session-level error).
[Serializable] structured cloning
Inputs & outputs. Marking WebTransportError as [Serializable] allows instances to pass through structuredClone(), Worker.postMessage() / MessageChannel, and IndexedDB storage. Blink’s module serializer (V8ScriptValueSerializerForModules::WriteDOMObject) writes a dedicated versioned tag (kWebTransportErrorTag) carrying four fields before delegating to the core DOMException serializer:
| Field | Preserved? | Details |
|---|---|---|
| Prototype / subtype | Yes | Deserializes as WebTransportError (cloned instanceof WebTransportError === true, name === "WebTransportError") |
message | Yes | UTF-8 DOMString preserved verbatim |
source | Yes | Validated enum discriminant ("stream" or "session") |
streamErrorCode | Yes | Presence flag (0/1) plus full 32-bit unsigned integer (or null) |
stack | No (reserved) | Wire format reserves an empty stack string in version 1; JS stack trace is intentionally not serialized |
Writer kill switch vs permanent decoder. Writer-side serialization is gated by RuntimeEnabledFeatures::WebTransportErrorSerializationEnabled(), while deserialization in V8ScriptValueDeserializerForModules::ReadDOMObject() remains permanently enabled so previously persisted IndexedDB records decode cleanly even if the writer switch is turned off.
Errors, edge cases, and recovery
TypeErroron invalidoptions.source& legacyWebTransportErrorInitclamping: passing asourcevalue other than"stream"or"session"throws a synchronousTypeError. Passing a dictionary as the first argument invokes Chromium’s legacyWebTransportErrorInitoverload, which silently clampsstreamErrorCodeto an 8-bit octet (0–255) and forcessourceto"stream".DataCloneError(DOMException) in older Chrome / when flag is off: before this feature is enabled, structured-cloning aWebTransportErrorfails withDataCloneError(or loses WebTransport fields if sliced toDOMException). Feature-detect by testingstructuredClone(new WebTransportError("probe", { streamErrorCode: 70000 }))and checkingclone instanceof WebTransportError && clone.streamErrorCode === 70000, falling back to plain-object DTO serialization when absent.- Corrupted serialized payloads: Blink’s deserializer rejects payloads with an unknown format version, out-of-range
sourcetag, invalid presence flag (> 1), malformed UTF-8, or truncated bytes, failing deserialization safely rather than constructing a malformed object. - Non-secure target context: deserialization checks
ExecutionContextExposesInterface; a non-secure context whereWebTransportErroris not exposed cannot deserialize aWebTransportErrorpayload.
Context and exposure
WebTransportError is exposed in Window and Worker (dedicated, shared, and service workers) and requires a Secure Context ([Exposed=(Window,Worker), Serializable, SecureContext]). Constructing or cloning a WebTransportError does not require an active WebTransport connection, permission, or user activation.
Lifecycle and state transitions
WebTransportError instances are immutable value objects once constructed: message, name, code, source, and streamErrorCode are read-only. They are created either by user agents when a stream or session fails over HTTP/3 / QUIC, or by application script passing an error reason to WritableStream.abort(reason) / ReadableStream.cancel(reason). Passing a WebTransportError through structuredClone(), postMessage(), or IndexedDB creates an independent copy in the receiving realm with identical message, source, and streamErrorCode (without retaining the original JS stack trace).
Examples
Standard constructor, 32-bit error code, and structured cloning across a Worker
// Standard W3C (message, options) constructor with a >255 32-bit error code
const err = new WebTransportError("Stream quota exceeded", {
source: "stream",
streamErrorCode: 70000,
});
console.log(err instanceof DOMException); // true
console.log(err.name); // "WebTransportError"
console.log(err.source); // "stream"
console.log(err.streamErrorCode); // 70000 (not truncated to 8 bits)
// Structured clone preserves subtype, message, source, and streamErrorCode
const cloned = structuredClone(err);
console.log(cloned instanceof WebTransportError); // true
console.log(cloned.streamErrorCode === 70000); // true
// Relay directly from a Worker to the Window via postMessage()
self.postMessage({ kind: "wt-error", error: err });
Source: Blink web_transport_error_test.cc; W3C WebTransport §12.
Cross-browser construction and clone feature detection
function createWebTransportErrorSafe(message, options = {}) {
const probe = new WebTransportError(message, options);
// Pre-159 Chromium ignored (message, options) and required the legacy WebTransportErrorInit dictionary
if (message && probe.message !== message) {
return new WebTransportError({
message,
streamErrorCode: options.streamErrorCode ?? 0,
});
}
return probe;
}
function canCloneWebTransportError() {
try {
const src = new WebTransportError("probe", { source: "session", streamErrorCode: 70000 });
const copy = structuredClone(src);
return (
copy instanceof WebTransportError &&
copy.message === "probe" &&
copy.source === "session" &&
copy.streamErrorCode === 70000
);
} catch {
return false;
}
}
Source: ChromeStatus 5158277221580800; Chrome Platform Showcase migration-shim concept.
Browser compatibility
| Browser | Alignment & serialization | Base WebTransportError (BCD) | Notes & evidence |
|---|---|---|---|
| Chrome (desktop, Android, WebView) | 159 (flag) 160 (target) | 97 | Developer trial behind #enable-experimental-web-platform-features in Chrome 159; shipping enabled by default targeted for Chrome 160 per ChromeStatus 5158277221580800. Retains legacy dictionary overload |
| Edge | Unknown (Chromium mirror) | 97 (mirror) | Chromium-based; follows Chromium milestone rollout |
| Firefox | Shipped | 114 | Standard constructor, 32-bit streamErrorCode, and serialization shipped per Bug 2009530 and WPT PR #63842 (exact release number not listed in BCD) |
| Safari | Shipped (26.4) | 26.4 | Standard constructor, 32-bit error code, and serialization implemented per WebKit Bug 305224 and BCD |
Security and privacy
Aligning WebTransportError and making it serializable grants no new network capability, reveals no new server or user information, and preserves WebTransport’s [SecureContext] restriction. Structured cloning copies only the WebTransportError subtype, DOMString message, source enum ("stream"/"session"), and nullable 32-bit streamErrorCode (stack traces are not serialized). Blink’s versioned decoder strictly validates the format version, enum discriminants, presence flag, UTF-8 code units, and payload length before instantiating a WebTransportError. ChromeStatus rates security risk as Low and lists formal security and privacy reviews as Pending (checked 2026-11-24).
Specifications
see also
- Chrome Platform Showcase — WebTransportError API alignment and serialization (5 interactive concepts)
- MDN —
WebTransportError - gendn Chrome 159 — WebTransport send groups and send-stream prioritization
- Chrome for Developers — Experimenting with WebTransport
- ChromeStatus — WebTransportError API alignment and serialization (5158277221580800)