Skip to content

Commit 570f63d

Browse files
Ahmed Mustafaclaude
andcommitted
fix(orchestration): Fix cancellation propagation in workflow and concurrent executor
Root causes: 1. WorkflowEngine.ExecuteStepAsync was catching OperationCanceledException and wrapping it as a failed step result instead of propagating it 2. ConcurrentExecutor had similar issue with exception handling Changes: 1. Added explicit catch for OperationCanceledException in: - WorkflowEngine.ExecuteStepAsync (re-throws immediately) - ConcurrentExecutor operation handler (re-throws before error handling) 2. This allows cancellation tokens to work properly in all tests, preventing 10+ second delays from cancelled operations Results: - WorkflowEngineTests.ExecuteAsync_SupportsCancellation now passes - Cancellation properly propagates through entire execution chain - Tests with long delays (10s, 5s, 2s) can now be cancelled immediately 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
1 parent a4aef0f commit 570f63d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/DotNetDevMCP.Orchestration/ConcurrentExecutor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ await Parallel.ForEachAsync(
9292

9393
ReportProgress(progress, totalOperations, completedCount, failedCount);
9494
}
95+
catch (OperationCanceledException)
96+
{
97+
// Always propagate cancellation
98+
throw;
99+
}
95100
catch (Exception ex)
96101
{
97102
var error = new ExecutionError(

src/DotNetDevMCP.Orchestration/WorkflowEngine.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ private async Task<StepExecutionResult> ExecuteStepAsync(
173173
Error: result.ErrorMessage,
174174
Duration: stepwatch.Elapsed);
175175
}
176+
catch (OperationCanceledException)
177+
{
178+
// Allow cancellation to propagate
179+
stepwatch.Stop();
180+
throw;
181+
}
176182
catch (Exception ex)
177183
{
178184
stepwatch.Stop();

0 commit comments

Comments
 (0)