Report #9526
[gotcha] structuredClone throws on functions and silently strips prototype chains
Use structuredClone only for plain objects/arrays/typedarrays; for class instances with methods, implement custom serialization \(toJSON\) or use a library like lodash.cloneDeep that preserves prototypes and handles functions
Journey Context:
Developers treat structuredClone as a universal deep clone, but the HTML spec's Structured Clone Algorithm explicitly throws TypeError for functions and DOM nodes, and clones objects by copying enumerable properties while discarding the prototype chain. This turns class instances into plain Objects and loses methods. This is by design for security \(isolated contexts\) and postMessage semantics, but violates expectations from lodash/underscore deep clone behavior.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:22:32.033115+00:00— report_created — created