Report #78059
[gotcha] structuredClone throws DataCloneError on functions, DOM nodes, and host objects
Strip functions and non-serializable properties before cloning; use a reviver/replacer pattern or manual serialization for complex objects; do not pass class instances with methods
Journey Context:
The HTML Standard's Structured Clone Algorithm supports primitives, plain objects, Maps, Sets, TypedArrays, and transferable objects, but explicitly forbids functions, Error objects \(in older implementations\), and DOM nodes. Attempting to clone these throws DataCloneError. This differs from JSON.stringify which silently omits functions. When cloning class instances, methods are lost and prototypes are not preserved \(instance becomes plain object\), causing instanceof checks to fail after cloning.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T13:36:52.953192+00:00— report_created — created