Skip to content

handling escalate action causes 'Maximum call stack size exceeded' #1550

Discussion options

You must be logged in to vote

The problem here has nothing to do with escalate(); rather, the always transition will always be taken in the E state (as the name implies).

Here's how to fix the infinite loop:

const machine = Machine({
  initial: "A",
  states: {
    A: {
      invoke: {
        src: childMachine,
        onError: {
          target: "E" // transitioning causes 'Maximum call stack size exceeded'
        }
      }
    },
    E: {
      always: {
        actions: (c, e) => console.log("E state", c, e),
+       target: "F"
      }
    },
+   F: {}
  }
  // ...
});

I'll add a warning for these scenarios.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kristofkalocsai
Comment options

Answer selected by kristofkalocsai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants