github statelyai/xstate xstate@6.0.0-alpha.55

latest releases: xstate@6.0.0-alpha.56, xstate@5.33.2
pre-release6 hours ago

Minor Changes

  • dcc21df: Route rejected promises returned from custom actions to the actor's error handling, so a state's onError catches a failed async action instead of leaving an unhandled rejection. A rejection that was previously ignored now errors the actor when no onError handles it.

    const machine = createMachine({
      initial: 'active',
      states: {
        active: {
          on: {
            SAVE: (_, enq) => {
              enq(() => saveToServer()); // returns a Promise
            }
          },
          onError: { target: 'failed' }
        },
        failed: {}
      }
    });

    Add the ErrorFrom type helper. invoke.onError events are typed from the invoked actor's error type when the actor logic declares one.

    Add an optional passive flag to Observer. A passive observer only tracks the actor's lifecycle and does not count as an error handler, so an unhandled actor error is still reported when every observer with an error callback is passive.

    An unhandled actor error is now reported one macrotask later than before, and a subscriber with an error callback that attaches in that window takes the error instead. Tests that advance fake timers by a single tick to observe the report need one more tick.

Patch Changes

  • df13f58: Fix TS4023 when exporting machines with state-level context schemas and function-form transitions while TypeScript declaration generation is enabled.

Don't miss a new xstate release

NewReleases is sending notifications on new releases.