#5077·xstate

Bug: Recreating a machine with children after getPersistedSnapshot results in an inability to persist it again

Author: iamquozCreated Sep 16, 2024Updated Dec 16, 2025
Labelsbug

XState version

XState version 5

Description

Sequence of events:

  1. Create a machine with children (either one or multiple of the same type)
  2. Create an actor and initialize the children machines through events of their parent
  3. Call getPersistsedSnapshot
  4. Try to create new actor from that snapshot
  5. If you reuse the same object, actor works fine and you can call getPersistedSnapshot on a new actor
  6. If you don't reuse it, and instead go through JSON.parse(JSON.serialize(...)), getPersistedSnapshot crashes when calling on a new actor.

Expected result

Restored actors continue to be persistable

Actual result

Restored actors fail to persist their children

Reproduction

https://codesandbox.io/p/devbox/gracious-jerry-njrg8n

Additional context

xstate 5.18.1 (latest)