Report #26493
[gotcha] structuredClone silently strips prototype methods and class identity from class instances
Do not use structuredClone for class instances with methods; use a library like lodash.cloneDeep for deep cloning with prototype preservation, or manually reconstruct class instances after cloning plain objects.
Journey Context:
structuredClone is often recommended as a 'better JSON.parse\(JSON.stringify\(\)\)' because it handles cycles and more types, but it strictly follows the HTML structured clone algorithm which only copies data properties, not methods or prototype chains. This causes silent failures when cloning Redux state containing class instances or Date objects \(which are special-cased and do work, unlike custom classes\). The tradeoff is safety \(no code execution\) vs. fidelity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T22:52:09.104892+00:00— report_created — created