fix(workflows-sdk): Miss match context usage within run as step (#12449)
**What** Currently, runAsStep keep reference of the workflow context that is being run as step, except that the step is composed for the current workflow composition and not the workflow being run as a step. Therefore, the context are currently miss matched leading to wrong configuration being used in case of async workflows. **BUG** This fix allow the runAsStep to use the current composition context to configure the step for the sub workflow to be run **BUG BREAKING** fix the step config wrongly used to wrap async step handlers. Now steps configured async through .config that returns a new step response will indeed marked itself as success without the need for background execution or calling setStepSuccess (as it was expected originally) **FEATURE** This pr also add support for cancelling running transaction, the transaction will be marked as being cancelled, once the current step finished, it will cancel the transaction to start compensating all previous steps including itself Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
ab22faaa52
commit
7fdbf2a965
@@ -3,6 +3,7 @@ import {
|
||||
IDistributedSchedulerStorage,
|
||||
IDistributedTransactionStorage,
|
||||
SchedulerOptions,
|
||||
SkipCancelledExecutionError,
|
||||
SkipExecutionError,
|
||||
TransactionCheckpoint,
|
||||
TransactionContext,
|
||||
@@ -290,6 +291,19 @@ export class InMemoryDistributedTransactionStorage
|
||||
throw new SkipExecutionError("Already finished by another execution")
|
||||
}
|
||||
|
||||
// First ensure that the latest execution was not cancelled, otherwise we skip the execution
|
||||
const latestTransactionCancelledAt = latestUpdatedFlow.cancelledAt
|
||||
const currentTransactionCancelledAt = currentFlow.cancelledAt
|
||||
|
||||
if (
|
||||
!!latestTransactionCancelledAt &&
|
||||
currentTransactionCancelledAt == null
|
||||
) {
|
||||
throw new SkipCancelledExecutionError(
|
||||
"Workflow execution has been cancelled during the execution"
|
||||
)
|
||||
}
|
||||
|
||||
const currentFlowSteps = Object.values(currentFlow.steps || {})
|
||||
const latestUpdatedFlowSteps = latestUpdatedFlow.steps
|
||||
? Object.values(
|
||||
|
||||
Reference in New Issue
Block a user