Skip to content

Commit dbd3275

Browse files
fix(overmind): correctly catch error during async execution
1 parent faf5ffa commit dbd3275

File tree

1 file changed

+25
-11
lines changed
  • packages/node_modules/overmind/src

1 file changed

+25
-11
lines changed

packages/node_modules/overmind/src/index.ts

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -581,18 +581,32 @@ export class Overmind<ThisConfig extends IConfiguration>
581581

582582
if (isPromise(result)) {
583583
this.eventHub.emit(EventType.OPERATOR_ASYNC, execution)
584-
result.then(() => {
585-
execution.isRunning = false
586-
if (!boundExecution) {
587-
mutationTree.dispose()
588-
}
589-
this.eventHub.emit(EventType.OPERATOR_END, {
590-
...execution,
591-
isAsync: true,
592-
result: undefined,
584+
result
585+
.then(() => {
586+
execution.isRunning = false
587+
if (!boundExecution) {
588+
mutationTree.dispose()
589+
}
590+
this.eventHub.emit(EventType.OPERATOR_END, {
591+
...execution,
592+
isAsync: true,
593+
result: undefined,
594+
})
595+
this.eventHub.emit(EventType.ACTION_END, execution)
596+
})
597+
.catch((error) => {
598+
execution.isRunning = false
599+
if (!boundExecution) {
600+
mutationTree.dispose()
601+
}
602+
this.eventHub.emit(EventType.OPERATOR_END, {
603+
...execution,
604+
isAsync: true,
605+
result: undefined,
606+
error: error.message,
607+
})
608+
this.eventHub.emit(EventType.ACTION_END, execution)
593609
})
594-
this.eventHub.emit(EventType.ACTION_END, execution)
595-
})
596610
} else {
597611
execution.isRunning = false
598612
if (!boundExecution) {

0 commit comments

Comments
 (0)