Skip to content

Machine exit actions have been called twice #2914

@huan

Description

@huan

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions