Skip to content

Commit

Permalink
Fix exiting of activity run loop when cancelled
Browse files Browse the repository at this point in the history
When a compensable activity cancelled the workflow, we need to keep running the loop in order to give the scheduled compensable activities a chance to perform the compensation branch.
  • Loading branch information
sfmskywalker committed Sep 9, 2023
1 parent 96ba86b commit 0091791
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/core/Elsa.Core/Services/Workflows/WorkflowRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,10 @@ private async ValueTask RunCoreAsync(WorkflowExecutionContext workflowExecutionC
if (workflowExecutionContext.Status == WorkflowStatus.Faulted)
{
await _mediator.Publish(new WorkflowFaulting(activityExecutionContext, activity), cancellationToken);
break;

// Only break out of loop if the status hasn't changed to Cancelled, in which case we might need to continue executing any scheduled compensation activities.
if (workflowExecutionContext.Status == WorkflowStatus.Faulted)
break;
}

await _mediator.Publish(new WorkflowExecutionPassCompleted(workflowExecutionContext, activityExecutionContext), cancellationToken);
Expand Down

0 comments on commit 0091791

Please sign in to comment.