Minor Changes
-
dcc21df: Route rejected promises returned from custom actions to the actor's error handling, so a state's
onErrorcatches a failed async action instead of leaving an unhandled rejection. A rejection that was previously ignored now errors the actor when noonErrorhandles it.const machine = createMachine({ initial: 'active', states: { active: { on: { SAVE: (_, enq) => { enq(() => saveToServer()); // returns a Promise } }, onError: { target: 'failed' } }, failed: {} } });
Add the
ErrorFromtype helper.invoke.onErrorevents are typed from the invoked actor's error type when the actor logic declares one.Add an optional
passiveflag toObserver. 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 anerrorcallback is passive.An unhandled actor error is now reported one macrotask later than before, and a subscriber with an
errorcallback 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.