Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
iamquoz opened this issue Sep 16, 2024 · 0 comments
Labels

Comments

@iamquoz
Copy link

iamquoz commented Sep 16, 2024

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)

@iamquoz iamquoz added the bug label Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant