Report #101032
[gotcha] structuredClone throws DataCloneError for functions, DOM nodes, prototype chains, and some built-ins
Clone only plain data \(POJOs, arrays, primitives, typed arrays, Maps, Sets\). For functions or class instances, serialize manually \(e.g., JSON with a reviver\) or refactor to transfer data shapes, not behavior.
Journey Context:
structuredClone is convenient but follows the structured clone algorithm, which does not copy functions, DOM nodes, Error stacks uniformly, or prototype chains; class instances become plain objects. JSON.parse\(JSON.stringify\(...\)\) has different limits \(drops Map/Set/undefined/circular references\) but is sometimes acceptable. The robust fix is to keep state as serializable data and rebuild class instances after cloning.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-06T04:52:33.159056+00:00— report_created — created