Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/fast-ears-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@medusajs/test-utils": patch
"@medusajs/orchestration": patch
---

fix(orchestration): Handle expected lifecycle errors
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ export class TransactionOrchestrator extends EventEmitter {
}
}

private static isExpectedError(error: Error): boolean {
return (
SkipCancelledExecutionError.isSkipCancelledExecutionError(error) ||
SkipExecutionError.isSkipExecutionError(error)
)
}

static clone(orchestrator: TransactionOrchestrator): TransactionOrchestrator {
return new TransactionOrchestrator({
id: orchestrator.id,
Expand Down Expand Up @@ -525,10 +532,7 @@ export class TransactionOrchestrator extends EventEmitter {
try {
await transaction.saveCheckpoint()
} catch (error) {
if (
!SkipCancelledExecutionError.isSkipCancelledExecutionError(error) &&
!SkipExecutionError.isSkipExecutionError(error)
) {
if (!TransactionOrchestrator.isExpectedError(error)) {
throw error
}

Expand Down Expand Up @@ -583,10 +587,7 @@ export class TransactionOrchestrator extends EventEmitter {
try {
await transaction.saveCheckpoint()
} catch (error) {
if (
!SkipCancelledExecutionError.isSkipCancelledExecutionError(error) &&
!SkipExecutionError.isSkipExecutionError(error)
) {
if (!TransactionOrchestrator.isExpectedError(error)) {
throw error
}

Expand Down Expand Up @@ -764,10 +765,7 @@ export class TransactionOrchestrator extends EventEmitter {
try {
await transaction.saveCheckpoint()
} catch (error) {
if (
!SkipCancelledExecutionError.isSkipCancelledExecutionError(error) &&
!SkipExecutionError.isSkipExecutionError(error)
) {
if (!TransactionOrchestrator.isExpectedError(error)) {
throw error
}

Expand Down Expand Up @@ -830,7 +828,7 @@ export class TransactionOrchestrator extends EventEmitter {
})

await transaction.saveCheckpoint().catch((error) => {
if (SkipExecutionError.isSkipExecutionError(error)) {
if (TransactionOrchestrator.isExpectedError(error)) {
continueExecution = false
return
}
Expand Down Expand Up @@ -900,7 +898,7 @@ export class TransactionOrchestrator extends EventEmitter {
}

await transaction.saveCheckpoint().catch((error) => {
if (!SkipExecutionError.isSkipExecutionError(error)) {
if (!TransactionOrchestrator.isExpectedError(error)) {
throw error
}
})
Expand Down Expand Up @@ -1063,7 +1061,7 @@ export class TransactionOrchestrator extends EventEmitter {
await this.handleStepSuccess(transaction, step, response)
})
.catch(async (error) => {
if (SkipExecutionError.isSkipExecutionError(error)) {
if (TransactionOrchestrator.isExpectedError(error)) {
return
}

Expand Down Expand Up @@ -1112,7 +1110,7 @@ export class TransactionOrchestrator extends EventEmitter {
}
})
.catch(async (error) => {
if (SkipExecutionError.isSkipExecutionError(error)) {
if (TransactionOrchestrator.isExpectedError(error)) {
return
}

Expand Down
2 changes: 1 addition & 1 deletion packages/medusa-test-utils/src/medusa-test-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface MedusaSuiteOptions {
}
getMedusaApp: () => MedusaAppOutput
utils: {
waitWorkflowExecutions: (container: MedusaContainer) => Promise<void>
waitWorkflowExecutions: () => Promise<void>
}
}

Expand Down