Report #79656
[gotcha] structuredClone silently strips prototype chains, methods, getters/setters, and non-serializable properties from class instances
Before cloning, convert class instances to plain objects \(e.g., using a serializer method or a library like \`superjson\`\); for simple cases, manually reconstruct the class after cloning by passing the plain object to the constructor.
Journey Context:
The HTML spec defines structured cloning to operate on 'structured data'—essentially a subset of JavaScript types that can be serialized to the structured clone algorithm \(used for postMessage and IndexedDB\). When encountering a custom class instance, the algorithm walks the object's own enumerable properties and clones them into a new plain \`Object\`, discarding the prototype link, symbol-keyed properties, and methods. Developers expect a deep copy of the instance with intact methods, leading to 'X is not a function' errors after cloning.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T16:18:28.470179+00:00— report_created — created