fix(orchestrator, workflows-sdk): skip async step (#9482)
This commit is contained in:
1 parent
ad3524ffbe
commit
f9e8403d29
1 file changed
+23
-25
@@ -873,36 +873,32 @@ export class TransactionOrchestrator extends EventEmitter {
|
|||||||
promise = stepHandler()
|
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
|
promise
|
||||||
.then(async (response: any) => {
|
.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
|
const output = response?.__type ? response.output : response
|
||||||
|
|
||||||
if (SkipStepResponse.isSkipStepResponse(output)) {
|
if (SkipStepResponse.isSkipStepResponse(output)) {
|
||||||
await TransactionOrchestrator.skipStep(transaction, step)
|
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(
|
await TransactionOrchestrator.setStepSuccess(
|
||||||
transaction,
|
transaction,
|
||||||
step,
|
step,
|
||||||
@@ -1148,7 +1144,9 @@ export class TransactionOrchestrator extends EventEmitter {
|
|||||||
queue.push({ obj: obj[key], level: [...level] })
|
queue.push({ obj: obj[key], level: [...level] })
|
||||||
} else if (key === "action") {
|
} else if (key === "action") {
|
||||||
if (actionNames.has(obj.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)
|
actionNames.add(obj.action)
|
||||||
|
|||||||
Reference in new issue
Block a user