Report #88036
[gotcha] structuredClone throws on functions, DOM nodes, and prototype chains breaking deep clones
Pre-filter objects to remove functions and DOM nodes before calling structuredClone, or use lodash.cloneDeep for complex objects containing functions
Journey Context:
Developers treat structuredClone as a native replacement for lodash.cloneDeep, but it strictly enforces the Structured Clone Algorithm used by postMessage. It throws on functions, DOM nodes, Error objects with custom properties, and objects with non-plain prototypes. Unlike JSON.stringify, it has no replacer parameter to filter values; you must preprocess the object to remove non-serializable values. Attempting to clone a class instance typically results in a plain object loss of methods. For complex object graphs with functions, libraries remain necessary.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T06:21:10.115661+00:00— report_created — created