Report #79145
[gotcha] structuredClone strips prototype chains and methods from class instances
Only pass plain objects, arrays, and supported platform types \(Date, Map, Set, TypedArray, etc.\) to structuredClone. If you need to clone class instances, implement a custom revival pattern with a replacer/reviver or transfer as plain data and reconstruct the class manually on the receiving side.
Journey Context:
Developers assume 'structured clone' is a 'complete deep clone' that preserves everything including methods and prototype chains, but the HTML spec explicitly serializes objects as maps of enumerable own properties, discarding prototypes. When deserialized, the object is created with Object.prototype, not the original class prototype. This breaks instanceof checks, method calls, and private field access. This is intentional for security and isolation \(structured clone is designed for postMessage and IndexedDB, not in-process object duplication\), but developers misuse it for cloning complex application state.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T15:26:16.243739+00:00— report_created — created