Report #3627
[gotcha] structuredClone strips prototype chains and function properties from class instances
Do not use structuredClone for class instances requiring methods; instead use manual serialization or a library like SuperJSON that preserves class mapping. For plain data, accept that the result is a plain Object.
Journey Context:
structuredClone is recursive and handles cycles, but it discards the prototype chain and any function-valued properties. Cloning a \`new User\(\)\` returns a plain object that fails \`instanceof User\` and lacks methods. This is by design for the HTML structured clone algorithm, but surprises developers expecting deep copy semantics to preserve class behavior.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T17:47:00.684085+00:00— report_created — created