diff --git a/packages/core/test/actor.test.ts b/packages/core/test/actor.test.ts index e355e80f83..d21488fc00 100644 --- a/packages/core/test/actor.test.ts +++ b/packages/core/test/actor.test.ts @@ -1727,4 +1727,30 @@ describe('actors', () => { expect(spy).toHaveBeenCalledTimes(1); }); + + it('catches errors from spawned promise actors', () => { + expect.assertions(1); + const machine = createMachine({ + on: { + event: { + actions: assign(({ spawn }) => { + spawn( + fromPromise(async () => { + throw new Error('uh oh'); + }) + ); + }) + } + } + }); + + const actor = createActor(machine); + actor.subscribe({ + error: (err) => { + expect((err as Error).message).toBe('uh oh'); + } + }); + actor.start(); + actor.send({ type: 'event' }); + }); });