fix(orchestrator): save checkpoint before async step (#12138)

This commit is contained in:
Carlos R. L. Rodrigues
2025-04-10 15:36:36 +00:00
committed by GitHub
parent 07252691c5
commit 31abba8cde
9 changed files with 33 additions and 31 deletions
@@ -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) {