[copilot-finds] Bug: Fix whenAll([]) hanging orchestration forever#118
Merged
YunchuWang merged 1 commit intomainfrom Mar 2, 2026
Merged
Conversation
whenAll([]) creates a WhenAllTask that never completes because no children exist to trigger onChildCompleted(). The condition _completedTasks == _tasks.length (0 == 0) inside onChildCompleted is never reached since the method is never called. This causes orchestrations to hang forever when using whenAll with a dynamically generated list that happens to be empty. Changes: - WhenAllTask: Immediately complete with [] when given an empty task array - WhenAnyTask: Throw an error for empty task array (matching .NET behavior) - RuntimeOrchestrationContext.run(): Handle already-complete initial yielded tasks by calling resume() immediately, enabling the generator to continue Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where whenAll([]) causes orchestrations to hang indefinitely because onChildCompleted() is never called for an empty task array, so the completion condition is never reached.
Changes:
WhenAllTask: Immediately marks itself as complete with an empty result when constructed with an empty array.WhenAnyTask: Throws an error on construction when given an empty array, matching .NET behavior.RuntimeOrchestrationContext: Detects already-complete tasks after a yield and callsresume()immediately.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/task/when-all-task.ts |
Marks WhenAllTask as immediately complete when given an empty task array |
src/task/when-any-task.ts |
Throws on empty task array in WhenAnyTask constructor |
src/worker/runtime-orchestration-context.ts |
Resumes generator immediately when the yielded task is already complete |
test/orchestration_executor.spec.ts |
Adds tests for whenAll([]), whenAll([]) followed by more work, and whenAny([]) |
kaibocai
approved these changes
Mar 2, 2026
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

whenAll([]) creates a WhenAllTask that never completes because no children exist to trigger onChildCompleted(). The condition _completedTasks == _tasks.length (0 == 0) inside onChildCompleted is never reached since the method is never called. This causes orchestrations to hang forever when using whenAll with a dynamically generated list that happens to be empty.
Changes:
Summary
What changed?
Why is this change needed?
Issues / work items
Project checklist
CHANGELOG.mdAI-assisted code disclosure (required)
Was an AI tool used? (select one)
If AI was used:
AI verification (required if AI was used):
Testing
Automated tests
Manual validation (only if runtime/behavior changed)
1.
2.
3.
Notes for reviewers