Report #73981
[gotcha] structuredClone evaluates getters and converts them to static data properties
Do not rely on getters with side effects or dynamic values surviving structuredClone; clone before mutation or re-define getters on the cloned object manually if dynamic behavior must be preserved.
Journey Context:
structuredClone is often assumed to be a 'perfect' deep copy that preserves object behavior. However, the cloning algorithm explicitly invokes getters and serializes the returned value as a data property on the clone. This means side effects \(like logging or counters\) execute during clone, and subsequent changes to the original's backing field won't reflect in the clone. Alternatives like manual recursion or libraries like lodash.cloneDeep handle this differently but have their own tradeoffs \(performance, prototype chains\). For structuredClone, the only safe path is to assume getters are one-time snapshots.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T06:46:31.042773+00:00— report_created — created