fix(orchestration): Use the step definition max retries on set step failure (#13319)

* fix(orchestration): Use the step definition max retries on set step failure

* Create sweet-turkeys-wait.md

* allow to force permanent failure

* update changeset
This commit is contained in:
Adrien de Peretti
2025-08-28 14:35:31 +02:00
committed by GitHub
parent cbaa403744
commit ff152e7ace
9 changed files with 64 additions and 15 deletions

View File

@@ -8,7 +8,7 @@ import { Context, LoadedModule, MedusaContainer } from "@medusajs/types"
type BaseFlowRunOptions = {
context?: Context
resultFrom?: string | string[] | Symbol
resultFrom?: string | Symbol
throwOnError?: boolean
logOnError?: boolean
events?: DistributedTransactionEvents
@@ -29,6 +29,7 @@ export type FlowRegisterStepFailureOptions<TData = unknown> =
BaseFlowRunOptions & {
idempotencyKey: string
response?: TData
forcePermanentFailure?: boolean
}
export type FlowCancelOptions = {

View File

@@ -71,6 +71,14 @@ function createContextualWorkflowRunner<
resultFrom,
isCancel = false,
container: executionContainer,
forcePermanentFailure,
}: {
throwOnError?: boolean
logOnError?: boolean
resultFrom?: string | Symbol
isCancel?: boolean
container?: LoadedModule[] | MedusaContainer
forcePermanentFailure?: boolean
},
transactionOrIdOrIdempotencyKey: DistributedTransactionType | string,
input: unknown,
@@ -107,13 +115,15 @@ function createContextualWorkflowRunner<
context.isCancelling = isCancel
const args = [
transactionOrIdOrIdempotencyKey,
input,
context,
events,
flowMetadata,
]
const args = [transactionOrIdOrIdempotencyKey, input, context, events]
if (method === originalRegisterStepFailure) {
// Only available on registerStepFailure
args.push(forcePermanentFailure)
} else {
args.push(flowMetadata)
}
const transaction = (await method.apply(
method,
args
@@ -161,7 +171,8 @@ function createContextualWorkflowRunner<
})
}
} else {
result = transaction.getContext().invoke?.[resultFrom]
result =
resultFrom && transaction.getContext().invoke?.[resultFrom.toString()]
}
return {
@@ -263,6 +274,7 @@ function createContextualWorkflowRunner<
resultFrom,
events,
container,
forcePermanentFailure,
}: FlowRegisterStepFailureOptions = {
idempotencyKey: "",
}
@@ -288,6 +300,7 @@ function createContextualWorkflowRunner<
resultFrom,
container,
logOnError,
forcePermanentFailure,
},
idempotencyKey,
response,