Report #6160
[gotcha] structuredClone silently strips prototype chains and methods from objects
Use class instances with explicit serialization methods \(toJSON\) or reconstruction logic after cloning; for complex state, use a dedicated serialization library \(protobuf, avro\) instead of structuredClone.
Journey Context:
structuredClone is deep but 'lossy' for custom classes: it clones properties into plain Objects, discarding the prototype chain and all methods. This causes 'method not found' errors when using the cloned instance. Alternatives like JSON.parse/stringify have similar issues but also don't support Map/Set/Date as well. The fix acknowledges that structuredClone is for 'plain data transfer' \(postMessage\), not object preservation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T23:17:13.413620+00:00— report_created — created