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: Root invocations should never be restarted #3072

Closed
davidkpiano opened this issue Feb 22, 2022 · 3 comments
Closed

Bug: Root invocations should never be restarted #3072

davidkpiano opened this issue Feb 22, 2022 · 3 comments

Comments

@davidkpiano
Copy link
Member

Description

See this thread: https://discord.com/channels/795785288994652170/799416943324823592/945378092552179753

Expected result

Root invocations are started when a machine is started, and only stopped when a machine is stopped.

Actual result

Root invocations can be restarted on external root transitions (which arguably should not be allowed).

Reproduction

https://codesandbox.io/s/unable-to-send-event-to-child-o5h24d?file=/src/index.ts:528-891

Additional context

Working example: https://codesandbox.io/s/unable-to-send-event-to-child-forked-e6bsn0?file=/src/index.ts:529-914

@davidkpiano davidkpiano changed the title Bug: Root invocations should be never restart Bug: Root invocations should never be restarted Feb 22, 2022
@Andarist
Copy link
Member

We've decided that we want to implement this behavior. However, we've also decided that this is not a critical fix - one can always use an internal transition to workaround this today. Changing this now creates an unnecessary risk of breaking some existing machine configuration - as this behavior was with us for quite some time.

I'm keeping this ticket open - so we can still adjust the behavior in v5 and once that is done then this ticket will get closed.

@davidkpiano
Copy link
Member Author

This is implemented in xstate@beta

@Andarist
Copy link
Member

Just note that we actually allow restarting root invocations - it's just that now transitions are "internal" by default and thus one shouldn't end up accidentally restarting a root invocation. A root invocation can still be restarted in v5 with a transition using reenter: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants