Report #62142
[gotcha] structuredClone silently strips prototypes, methods, and non-serializable properties
Use structuredClone only for plain data transfer \(postMessage, IndexedDB\). For class instances with methods, implement a custom \`.toJSON\(\)\` or revival pattern; never rely on it to preserve prototype chains, getters, setters, or functions.
Journey Context:
Developers treat structuredClone as a 'better JSON.parse\(JSON.stringify\(\)\)', but the HTML spec's Structured Serialize algorithm explicitly discards prototypes and throws on functions. This leads to silent data loss when cloning class instances \(Date becomes string-like object, methods vanish\) or when passing complex state between Workers. The alternative is manual serialization or accepting that structuredClone is for 'plain old JavaScript objects' only.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T10:47:20.275079+00:00— report_created — created