fix(orchestrator): save checkpoint before async step (#12138)
This commit is contained in:
@@ -741,7 +741,6 @@ export class TransactionOrchestrator extends EventEmitter {
|
||||
this.emit(DistributedTransactionEvent.FINISH, { transaction })
|
||||
}
|
||||
|
||||
const asyncStepsToStart: any[] = []
|
||||
for (const step of nextSteps.next) {
|
||||
const curState = step.getStates()
|
||||
const type = step.isCompensating()
|
||||
@@ -924,8 +923,8 @@ export class TransactionOrchestrator extends EventEmitter {
|
||||
return await transaction.handler(...handlerArgs)
|
||||
}
|
||||
|
||||
asyncStepsToStart.push({
|
||||
handler: async () => {
|
||||
execution.push(
|
||||
transaction.saveCheckpoint().then(() => {
|
||||
let promise: Promise<unknown>
|
||||
|
||||
if (TransactionOrchestrator.traceStep) {
|
||||
@@ -937,7 +936,7 @@ export class TransactionOrchestrator extends EventEmitter {
|
||||
promise = stepHandler()
|
||||
}
|
||||
|
||||
return promise
|
||||
promise
|
||||
.then(async (response: any) => {
|
||||
const output = response?.__type ? response.output : response
|
||||
|
||||
@@ -991,8 +990,8 @@ export class TransactionOrchestrator extends EventEmitter {
|
||||
response,
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1006,10 +1005,6 @@ export class TransactionOrchestrator extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
if (asyncStepsToStart.length > 0) {
|
||||
execution.push(...asyncStepsToStart.map((step) => step.handler()))
|
||||
}
|
||||
|
||||
await promiseAll(execution)
|
||||
|
||||
if (nextSteps.next.length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user