fix(orchestrator, workflows-sdk): skip async step (#9482)
This commit is contained in:
committed by
GitHub
parent
ad3524ffbe
commit
f9e8403d29
@@ -873,36 +873,32 @@ export class TransactionOrchestrator extends EventEmitter {
|
||||
promise = stepHandler()
|
||||
}
|
||||
|
||||
// TODO discussion why do we not await here, adding an await I wouldnt expect the test to fail but it does, maybe we should split the test to also test after everything is executed?
|
||||
// cc test from engine redis
|
||||
promise
|
||||
.then(async (response: any) => {
|
||||
if (
|
||||
!step.definition.backgroundExecution ||
|
||||
step.definition.nested
|
||||
) {
|
||||
const eventName = DistributedTransactionEvent.STEP_AWAITING
|
||||
transaction.emit(eventName, { step, transaction })
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (this.hasExpired({ transaction, step }, Date.now())) {
|
||||
await this.checkStepTimeout(transaction, step)
|
||||
await this.checkTransactionTimeout(
|
||||
transaction,
|
||||
nextSteps.next.includes(step) ? nextSteps.next : [step]
|
||||
)
|
||||
}
|
||||
|
||||
let setResponse = true
|
||||
const output = response?.__type ? response.output : response
|
||||
|
||||
if (SkipStepResponse.isSkipStepResponse(output)) {
|
||||
await TransactionOrchestrator.skipStep(transaction, step)
|
||||
setResponse = false
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
!step.definition.backgroundExecution ||
|
||||
step.definition.nested
|
||||
) {
|
||||
const eventName =
|
||||
DistributedTransactionEvent.STEP_AWAITING
|
||||
transaction.emit(eventName, { step, transaction })
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (this.hasExpired({ transaction, step }, Date.now())) {
|
||||
await this.checkStepTimeout(transaction, step)
|
||||
await this.checkTransactionTimeout(
|
||||
transaction,
|
||||
nextSteps.next.includes(step) ? nextSteps.next : [step]
|
||||
)
|
||||
}
|
||||
|
||||
if (setResponse) {
|
||||
await TransactionOrchestrator.setStepSuccess(
|
||||
transaction,
|
||||
step,
|
||||
@@ -1148,7 +1144,9 @@ export class TransactionOrchestrator extends EventEmitter {
|
||||
queue.push({ obj: obj[key], level: [...level] })
|
||||
} else if (key === "action") {
|
||||
if (actionNames.has(obj.action)) {
|
||||
throw new Error(`Step ${obj.action} is already defined in workflow.`)
|
||||
throw new Error(
|
||||
`Step ${obj.action} is already defined in workflow.`
|
||||
)
|
||||
}
|
||||
|
||||
actionNames.add(obj.action)
|
||||
|
||||
Reference in New Issue
Block a user