Report #6758
[gotcha] structuredClone strips prototype chain and methods from class instances
Treat structuredClone results as plain data transfer objects \(DTOs\); manually reattach prototypes or use factory functions to reconstruct class instances after cloning.
Journey Context:
structuredClone uses the Structured Serialize algorithm which walks internal slots and enumerable properties but discards prototype references and function objects. Developers cloning class instances expect methods to survive, resulting in 'is not a function' errors when calling methods on the clone. Alternatives like manual serialization or libraries like \`flatted\` preserve structure but not methods; the correct pattern is separating data \(cloned\) from behavior \(reattached via constructor or Object.setPrototypeOf\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T00:49:48.271561+00:00— report_created — created