Skip to content

Commit e9a33d0

Browse files
authored
fix(orchestration): Handle expected lifecycle errors (#12886)
* fix(orchestration): Handle expected lifecycle errors * fix(orchestration): Handle expected lifecycle errors * Create fast-ears-own.md
1 parent a7700f1 commit e9a33d0

3 files changed

Lines changed: 21 additions & 17 deletions

File tree

.changeset/fast-ears-own.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@medusajs/test-utils": patch
3+
"@medusajs/orchestration": patch
4+
---
5+
6+
fix(orchestration): Handle expected lifecycle errors

packages/core/orchestration/src/transaction/transaction-orchestrator.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ export class TransactionOrchestrator extends EventEmitter {
113113
}
114114
}
115115

116+
private static isExpectedError(error: Error): boolean {
117+
return (
118+
SkipCancelledExecutionError.isSkipCancelledExecutionError(error) ||
119+
SkipExecutionError.isSkipExecutionError(error)
120+
)
121+
}
122+
116123
static clone(orchestrator: TransactionOrchestrator): TransactionOrchestrator {
117124
return new TransactionOrchestrator({
118125
id: orchestrator.id,
@@ -525,10 +532,7 @@ export class TransactionOrchestrator extends EventEmitter {
525532
try {
526533
await transaction.saveCheckpoint()
527534
} catch (error) {
528-
if (
529-
!SkipCancelledExecutionError.isSkipCancelledExecutionError(error) &&
530-
!SkipExecutionError.isSkipExecutionError(error)
531-
) {
535+
if (!TransactionOrchestrator.isExpectedError(error)) {
532536
throw error
533537
}
534538

@@ -583,10 +587,7 @@ export class TransactionOrchestrator extends EventEmitter {
583587
try {
584588
await transaction.saveCheckpoint()
585589
} catch (error) {
586-
if (
587-
!SkipCancelledExecutionError.isSkipCancelledExecutionError(error) &&
588-
!SkipExecutionError.isSkipExecutionError(error)
589-
) {
590+
if (!TransactionOrchestrator.isExpectedError(error)) {
590591
throw error
591592
}
592593

@@ -764,10 +765,7 @@ export class TransactionOrchestrator extends EventEmitter {
764765
try {
765766
await transaction.saveCheckpoint()
766767
} catch (error) {
767-
if (
768-
!SkipCancelledExecutionError.isSkipCancelledExecutionError(error) &&
769-
!SkipExecutionError.isSkipExecutionError(error)
770-
) {
768+
if (!TransactionOrchestrator.isExpectedError(error)) {
771769
throw error
772770
}
773771

@@ -830,7 +828,7 @@ export class TransactionOrchestrator extends EventEmitter {
830828
})
831829

832830
await transaction.saveCheckpoint().catch((error) => {
833-
if (SkipExecutionError.isSkipExecutionError(error)) {
831+
if (TransactionOrchestrator.isExpectedError(error)) {
834832
continueExecution = false
835833
return
836834
}
@@ -900,7 +898,7 @@ export class TransactionOrchestrator extends EventEmitter {
900898
}
901899

902900
await transaction.saveCheckpoint().catch((error) => {
903-
if (!SkipExecutionError.isSkipExecutionError(error)) {
901+
if (!TransactionOrchestrator.isExpectedError(error)) {
904902
throw error
905903
}
906904
})
@@ -1063,7 +1061,7 @@ export class TransactionOrchestrator extends EventEmitter {
10631061
await this.handleStepSuccess(transaction, step, response)
10641062
})
10651063
.catch(async (error) => {
1066-
if (SkipExecutionError.isSkipExecutionError(error)) {
1064+
if (TransactionOrchestrator.isExpectedError(error)) {
10671065
return
10681066
}
10691067

@@ -1112,7 +1110,7 @@ export class TransactionOrchestrator extends EventEmitter {
11121110
}
11131111
})
11141112
.catch(async (error) => {
1115-
if (SkipExecutionError.isSkipExecutionError(error)) {
1113+
if (TransactionOrchestrator.isExpectedError(error)) {
11161114
return
11171115
}
11181116

packages/medusa-test-utils/src/medusa-test-runner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export interface MedusaSuiteOptions {
3636
}
3737
getMedusaApp: () => MedusaAppOutput
3838
utils: {
39-
waitWorkflowExecutions: (container: MedusaContainer) => Promise<void>
39+
waitWorkflowExecutions: () => Promise<void>
4040
}
4141
}
4242

0 commit comments

Comments
 (0)