Report #27451
[gotcha] structuredClone silently strips prototypes and drops all methods from class instances
Implement custom serialization with \`toJSON\(\)\` and revival logic, or use libraries like \`devalue\` that preserve class metadata, or convert to plain objects before cloning
Journey Context:
structuredClone uses StructuredSerializeInternal which serializes enumerable own properties but resets the prototype to Object.prototype and discards methods. This causes class instances to lose all behavior and custom prototype chains after cloning. The silent nature is dangerous because the object appears intact \(same properties\) but methods throw TypeError or return undefined. Alternatives like JSON.parse\(JSON.stringify\(\)\) have similar issues but are expected; structuredClone's limitation is less known because it handles more types \(Maps, Sets, ArrayBuffers\) making it appear more "complete".
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T00:28:26.164074+00:00— report_created — created