docs.rodeo

MDN Web Docs mirror

The structured clone algorithm

{{DefaultAPISidebar("Web Workers API") }} 

The structured clone algorithm copies complex JavaScript objects. It is used internally when invoking {{DOMxRef("WorkerGlobalScope.structuredClone", "structuredClone()")}} , to transfer data between Workers via {{domxref("Worker.postMessage()", "postMessage()")}} , storing objects with IndexedDB, or copying objects for other APIs.

It clones by recursing through the input object while maintaining a map of previously visited references, to avoid infinitely traversing cycles.

Things that don’t work with structured clone

Supported types

JavaScript types

Error types

For Error types, the error name must be one of: {{jsxref("Error")}} , {{JSxRef("EvalError")}} , {{JSxRef("RangeError")}} , {{JSxRef("ReferenceError")}} , {{JSxRef("SyntaxError")}} , {{JSxRef("TypeError")}} , {{JSxRef("URIError")}}  (or will be set to “Error”).

Browsers must serialize the properties name and message, and are expected to serialize other “interesting” properties of the errors such as stack, cause, etc.

{{JSxRef("AggregateError")}}  support is expected to be added to the specification in whatwg/html#5749 (and is already supported in some browsers).

Web/API types

[!NOTE] Serializable objects are marked up in Web IDL files with the attribute [Serializable].

See also

In this article

View on MDN