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

Machine exit actions have been called twice #2914

Closed
huan opened this issue Jan 3, 2022 · 5 comments
Closed

Machine exit actions have been called twice #2914

huan opened this issue Jan 3, 2022 · 5 comments

Comments

@huan
Copy link
Contributor

huan commented Jan 3, 2022

Description

I have a machine with two children: one is spawn-ed and the other is invoke-ed.

They all have entry and exit actions which is a spy for testing.

Expected Result

after the interpreter.stop(), the parent and two children exit actions will be called once.

Actual Result

They have been called twice instead of once.

Reproduction

https://github.com/wechaty/bot5-assistant/blob/ffb902ebfa2513630a92309ce9091a28c80dbdfc/src/mailbox/xstate-child-exit-order.spec.ts#L61-L68

Additional context

I want to do cleanup whenever the machine (actor) has been stopped.

One more thing: I noticed that the exit order is not the same as the entry order.

  • Entry order: spawn, invoke, parent
  • Exit order: parent, spawn, invoke

I think the exit order should be exactly the reverse order of the entry?

@Andarist
Copy link
Member

Andarist commented Jan 3, 2022

Have you tried with 4.27.0? This should have been just fixed there: https://github.com/statelyai/xstate/releases/tag/xstate%404.27.0

huan added a commit to wechaty/bot5-assistant that referenced this issue Jan 3, 2022
huan added a commit to wechaty/bot5-assistant that referenced this issue Jan 3, 2022
@huan
Copy link
Contributor Author

huan commented Jan 3, 2022

@Andarist Thank you very much for the information!

I can confirm that this issue has been fixed by the 4.27 (#2895), appreciate your fix!

@huan
Copy link
Contributor Author

huan commented Jan 3, 2022

And may I ask your option for the exit order is not as same as the entry order problem?

  • Entry order: spawn, invoke, parent
  • Exit order: parent, spawn, invoke

I think the exit order should be exactly the reverse order of the entry, or do we have any reason that make those order like this?

@Andarist
Copy link
Member

Andarist commented Jan 3, 2022

The exit actions order is being fixed here: #2903

@huan
Copy link
Contributor Author

huan commented Jan 3, 2022

Aha, brilliant!

@huan huan closed this as completed Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants