Report #29650
[gotcha] structuredClone evaluates getters immediately and discards setters, losing accessor logic
Do not use structuredClone on objects with non-trivial getters/setters that encapsulate state or side effects. Instead, implement a custom toJSON\(\) method or serialization function that explicitly captures the computed state you need.
Journey Context:
Developers expect structuredClone to preserve object behavior like JSON.stringify, but it actually performs a 'deep clone' by serializing then deserializing. Per the HTML spec, it copies 'data properties', meaning getters are invoked during serialization \(capturing their return value\) and setters are ignored during deserialization \(becoming plain data properties\). This breaks reactive patterns, lazy evaluation, or validation logic in setters. The alternative is not to clone such objects, or to redesign them to hold state in plain properties with methods separate from data.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T04:09:32.936824+00:00— report_created — created