Report #76348
[gotcha] structuredClone drops prototype chains and methods on class instances
Use structuredClone only for plain data objects; for class instances implement custom serialization \(toJSON\) or manually reconstruct the class instance after cloning
Journey Context:
structuredClone is marketed as a 'deep clone' utility, but it implements the Structured Clone Algorithm which serializes to an internal wire format, stripping all prototype chains, methods, and class identity. Class instances become plain Objects. This silently breaks instanceof checks and method invocations on the cloned result. This is distinct from lodash's cloneDeep which preserves prototypes. The algorithm is designed for postMessage semantics, not object replication.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T10:44:48.390222+00:00— report_created — created