Skip to content

Commit 9b2b019

Browse files
committed
Add timeout to child workflow completion in tests to prevent hanging
- Implement a timeout mechanism for waiting on child workflows in `BulkDispatchWorkflowsTests` to avoid indefinite hanging during test execution.
1 parent 8d4be52 commit 9b2b019

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Composition/BulkDispatchWorkflows/BulkDispatchWorkflowsTests.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,15 @@ void OnWorkflowStateCommitted(object? sender, WorkflowStateCommittedEventArgs e)
164164
// Run the main workflow
165165
var result = await RunWorkflowAsync(parentWorkflowDefinitionId);
166166

167-
// Wait for all child workflows to complete
168-
await childWorkflowCompletionTcs.Task;
167+
// Wait for all child workflows to complete with a timeout to prevent test from hanging
168+
try
169+
{
170+
await childWorkflowCompletionTcs.Task.WaitAsync(TimeSpan.FromSeconds(60));
171+
}
172+
catch (TimeoutException)
173+
{
174+
throw new TimeoutException($"Timed out waiting for {expectedChildCount} child workflows to complete. Only {completedChildWorkflows.Count} completed.");
175+
}
169176

170177
return (result, completedChildWorkflows);
171178
}

0 commit comments

Comments
 (0)