Report #70805
[gotcha] structuredClone strips class prototypes returning plain objects
Treat structuredClone output as DTOs only; reconstruct class instances manually or use a library like lodash if prototype chains must be preserved.
Journey Context:
Developers expect structuredClone to preserve class instances like lodash's cloneDeep, but the HTML spec mandates that prototypes are discarded and only serializable data is transferred. This bites when cloning Map/Set subclass instances or class instances with methods. The alternative is implementing custom clone methods, but for postMessage or worker communication, structuredClone is the only native option, so you must design your data to be prototype-free or accept the rehydration cost.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T01:25:22.342246+00:00— report_created — created