fix(orchestration): fix set step failure (#10031)
What: - copy data before saving checkpoint - removed unused data format function - properly handle registerStepFailure to not throw - emit onFinish event even when execution failed
This commit is contained in:
committed by
GitHub
parent
7794faf49e
commit
1eef324af3
@@ -131,17 +131,20 @@ export class WorkflowOrchestratorService {
|
||||
options?: WorkflowOrchestratorRunOptions<T>,
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
) {
|
||||
let {
|
||||
const {
|
||||
input,
|
||||
context,
|
||||
transactionId,
|
||||
resultFrom,
|
||||
throwOnError,
|
||||
logOnError,
|
||||
events: eventHandlers,
|
||||
container,
|
||||
} = options ?? {}
|
||||
|
||||
let { throwOnError, context } = options ?? {}
|
||||
throwOnError ??= true
|
||||
context ??= {}
|
||||
context.transactionId ??= transactionId ?? ulid()
|
||||
|
||||
const workflowId = isString(workflowIdOrWorkflow)
|
||||
? workflowIdOrWorkflow
|
||||
: workflowIdOrWorkflow.getName()
|
||||
@@ -153,9 +156,6 @@ export class WorkflowOrchestratorService {
|
||||
)
|
||||
}
|
||||
|
||||
context ??= {}
|
||||
context.transactionId ??= transactionId ?? ulid()
|
||||
|
||||
const events: FlowRunOptions["events"] = this.buildWorkflowEvents({
|
||||
customEventHandlers: eventHandlers,
|
||||
workflowId,
|
||||
@@ -172,7 +172,7 @@ export class WorkflowOrchestratorService {
|
||||
|
||||
const ret = await exportedWorkflow.run({
|
||||
input,
|
||||
throwOnError,
|
||||
throwOnError: false,
|
||||
logOnError,
|
||||
resultFrom,
|
||||
context,
|
||||
@@ -210,6 +210,10 @@ export class WorkflowOrchestratorService {
|
||||
await this.triggerParentStep(ret.transaction, result)
|
||||
}
|
||||
|
||||
if (throwOnError && ret.thrownError) {
|
||||
throw ret.thrownError
|
||||
}
|
||||
|
||||
return { acknowledgement, ...ret }
|
||||
}
|
||||
|
||||
@@ -262,13 +266,15 @@ export class WorkflowOrchestratorService {
|
||||
) {
|
||||
const {
|
||||
context,
|
||||
throwOnError,
|
||||
logOnError,
|
||||
resultFrom,
|
||||
container,
|
||||
events: eventHandlers,
|
||||
} = options ?? {}
|
||||
|
||||
let { throwOnError } = options ?? {}
|
||||
throwOnError ??= true
|
||||
|
||||
const [idempotencyKey_, { workflowId, transactionId }] =
|
||||
this.buildIdempotencyKeyAndParts(idempotencyKey)
|
||||
|
||||
@@ -287,7 +293,7 @@ export class WorkflowOrchestratorService {
|
||||
idempotencyKey: idempotencyKey_,
|
||||
context,
|
||||
resultFrom,
|
||||
throwOnError,
|
||||
throwOnError: false,
|
||||
logOnError,
|
||||
events,
|
||||
response: stepResponse,
|
||||
@@ -308,6 +314,10 @@ export class WorkflowOrchestratorService {
|
||||
await this.triggerParentStep(ret.transaction, result)
|
||||
}
|
||||
|
||||
if (throwOnError && ret.thrownError) {
|
||||
throw ret.thrownError
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -326,13 +336,15 @@ export class WorkflowOrchestratorService {
|
||||
) {
|
||||
const {
|
||||
context,
|
||||
throwOnError,
|
||||
logOnError,
|
||||
resultFrom,
|
||||
container,
|
||||
events: eventHandlers,
|
||||
} = options ?? {}
|
||||
|
||||
let { throwOnError } = options ?? {}
|
||||
throwOnError ??= true
|
||||
|
||||
const [idempotencyKey_, { workflowId, transactionId }] =
|
||||
this.buildIdempotencyKeyAndParts(idempotencyKey)
|
||||
|
||||
@@ -351,7 +363,7 @@ export class WorkflowOrchestratorService {
|
||||
idempotencyKey: idempotencyKey_,
|
||||
context,
|
||||
resultFrom,
|
||||
throwOnError,
|
||||
throwOnError: false,
|
||||
logOnError,
|
||||
events,
|
||||
response: stepResponse,
|
||||
@@ -372,6 +384,10 @@ export class WorkflowOrchestratorService {
|
||||
await this.triggerParentStep(ret.transaction, result)
|
||||
}
|
||||
|
||||
if (throwOnError && ret.thrownError) {
|
||||
throw ret.thrownError
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user