xstate-viz icon indicating copy to clipboard operation
xstate-viz copied to clipboard

Simple machine configuration breaks the visualizer

Open davidlav opened this issue 3 years ago • 0 comments

Description

First off, apologies for the bad title, but I really have no insight into what's not working. Feel free to rename.

My, seemingly simple, machine won't render. It's not a terribly sensible machine, but that's because I reduced it from 182 lines to about 25 to produce a minimum-non-functioning example.

Expected Result

The machine config should render correctly, as it does in the old visualizer:

image

Actual Result

The new visualizer just hangs on "Visualizing machine...".

image

With the following console errors:

Chrome

image

Firefox

image image

Reproduction

Enter the following into stately.ai/viz:

import { createMachine } from "xstate";

createMachine({
  id: "Top",
  initial: "first",
  states: {
    first: {
      on: { MOVE: "second" },
    },
    second: {
      initial: "firstSubstate",
      states: {
        firstSubstate: {
          on: {
            BACK: "#Top.first.",
            NEXT: "secondSubstate",
          },
        },
        secondSubstate: {
          initial: "subSubState",
          states: { subSubState: {} },
        },
      },
    },
  },
});

Additional context

Several things seem to "solve" the problem:

  1. Removing the BACK transition

image

  1. Removing the NEXT transtition

image

  1. Removing the subSubState from the secondSubstate

image

  1. Strangest of all, adding an additional, thirdSubstate to second (line 23)

image

davidlav avatar Mar 24 '22 17:03 davidlav