79746352

Date: 2025-08-26 02:00:07
Score: 0.5
Natty:
Report link

After some digging, I found that Objects wrapped in a Svelte 5 state rune don't behave just like a normal Object (unlike in Svelte 4), as $state(...) wraps plain objects/arrays in a Svelte Proxy. This is what led to the error: IndexedDB (and Node’s structuredClone) cannot serialize these Proxies, so Dexie throws DataCloneError: #<Object> could not be cloned. The fix is to simply replace the plain object spread with $state.snapshot(), which takes a static serializable snapshot of a deeply reactive $state proxy:

- const dirty = { meta: { ...meta } }
+ const dirty = { meta: $state.snapshot(meta) }
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: henrymattel