fix(orchestration): Handle expected lifecycle errors (#12886)
* fix(orchestration): Handle expected lifecycle errors * fix(orchestration): Handle expected lifecycle errors * Create fast-ears-own.md
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/test-utils": patch
|
||||||
|
"@medusajs/orchestration": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(orchestration): Handle expected lifecycle errors
|
||||||
@@ -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 {
|
static clone(orchestrator: TransactionOrchestrator): TransactionOrchestrator {
|
||||||
return new TransactionOrchestrator({
|
return new TransactionOrchestrator({
|
||||||
id: orchestrator.id,
|
id: orchestrator.id,
|
||||||
@@ -525,10 +532,7 @@ export class TransactionOrchestrator extends EventEmitter {
|
|||||||
try {
|
try {
|
||||||
await transaction.saveCheckpoint()
|
await transaction.saveCheckpoint()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (
|
if (!TransactionOrchestrator.isExpectedError(error)) {
|
||||||
!SkipCancelledExecutionError.isSkipCancelledExecutionError(error) &&
|
|
||||||
!SkipExecutionError.isSkipExecutionError(error)
|
|
||||||
) {
|
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -583,10 +587,7 @@ export class TransactionOrchestrator extends EventEmitter {
|
|||||||
try {
|
try {
|
||||||
await transaction.saveCheckpoint()
|
await transaction.saveCheckpoint()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (
|
if (!TransactionOrchestrator.isExpectedError(error)) {
|
||||||
!SkipCancelledExecutionError.isSkipCancelledExecutionError(error) &&
|
|
||||||
!SkipExecutionError.isSkipExecutionError(error)
|
|
||||||
) {
|
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -764,10 +765,7 @@ export class TransactionOrchestrator extends EventEmitter {
|
|||||||
try {
|
try {
|
||||||
await transaction.saveCheckpoint()
|
await transaction.saveCheckpoint()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (
|
if (!TransactionOrchestrator.isExpectedError(error)) {
|
||||||
!SkipCancelledExecutionError.isSkipCancelledExecutionError(error) &&
|
|
||||||
!SkipExecutionError.isSkipExecutionError(error)
|
|
||||||
) {
|
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -830,7 +828,7 @@ export class TransactionOrchestrator extends EventEmitter {
|
|||||||
})
|
})
|
||||||
|
|
||||||
await transaction.saveCheckpoint().catch((error) => {
|
await transaction.saveCheckpoint().catch((error) => {
|
||||||
if (SkipExecutionError.isSkipExecutionError(error)) {
|
if (TransactionOrchestrator.isExpectedError(error)) {
|
||||||
continueExecution = false
|
continueExecution = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -900,7 +898,7 @@ export class TransactionOrchestrator extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await transaction.saveCheckpoint().catch((error) => {
|
await transaction.saveCheckpoint().catch((error) => {
|
||||||
if (!SkipExecutionError.isSkipExecutionError(error)) {
|
if (!TransactionOrchestrator.isExpectedError(error)) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -1063,7 +1061,7 @@ export class TransactionOrchestrator extends EventEmitter {
|
|||||||
await this.handleStepSuccess(transaction, step, response)
|
await this.handleStepSuccess(transaction, step, response)
|
||||||
})
|
})
|
||||||
.catch(async (error) => {
|
.catch(async (error) => {
|
||||||
if (SkipExecutionError.isSkipExecutionError(error)) {
|
if (TransactionOrchestrator.isExpectedError(error)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1112,7 +1110,7 @@ export class TransactionOrchestrator extends EventEmitter {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(async (error) => {
|
.catch(async (error) => {
|
||||||
if (SkipExecutionError.isSkipExecutionError(error)) {
|
if (TransactionOrchestrator.isExpectedError(error)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export interface MedusaSuiteOptions {
|
|||||||
}
|
}
|
||||||
getMedusaApp: () => MedusaAppOutput
|
getMedusaApp: () => MedusaAppOutput
|
||||||
utils: {
|
utils: {
|
||||||
waitWorkflowExecutions: (container: MedusaContainer) => Promise<void>
|
waitWorkflowExecutions: () => Promise<void>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user