xstate icon indicating copy to clipboard operation
xstate copied to clipboard

Bug: Maximum call stack exceeded on hot reload when assigning element to context

Open jjenzz opened this issue 1 year ago • 2 comments

XState version

XState version 5

Description

in a NextJS 14 app router project, i'm assigning an element to context on mount. if i make changes to my code that trigger a hot reload, i get the following errors:

CleanShot 2024-07-16 at 17 09 56

i can only replicate this when assigning an HTMLElement. assigning a string works fine.

Steps to reproduce

  • open the StackBlitz
  • open devtools and enable preserve logs
  • change the contents of the <div> to trigger a hot reload
  • observe the preserved errors in the log

https://github.com/user-attachments/assets/4019fa36-40fc-4b8f-ab81-eab98f9f9543

Expected result

hot reload would succeed without errors

Actual result

maximum call stack exceeded

Reproduction

https://stackblitz.com/edit/stackblitz-starters-hocxhz?description=The%20React%20framework%20for%20production&file=app%2Ftest.tsx,app%2Fpage.tsx&title=Next.js%20Starter

Additional context

No response

jjenzz avatar Jul 16 '24 16:07 jjenzz

I believe this is a duplicate of: https://github.com/statelyai/xstate/issues/4645

Andarist avatar Jul 16 '24 16:07 Andarist

Thanks for the repro! Seems like the issue is with the persistContext(…) function getting into a cycle. Will investigate.

davidkpiano avatar Jul 16 '24 22:07 davidkpiano