Fix WhenAllTask crash when children complete after fail-fast#123
Open
YunchuWang wants to merge 1 commit intomainfrom
Open
Fix WhenAllTask crash when children complete after fail-fast#123YunchuWang wants to merge 1 commit intomainfrom
YunchuWang wants to merge 1 commit intomainfrom
Conversation
WhenAllTask.onChildCompleted() had two bugs: 1. Threw 'Task is already completed' when a child completed after the WhenAllTask had already failed via fail-fast. This crashed orchestrations when multiple activities were in a WhenAll and one failed while others completed in the same or subsequent event batch. 2. Fell through from the fail-fast block to the result-collection block when the failing task was the last child to complete, causing getResult() to throw on the failed task. Fixes: - Change throw to return in onChildCompleted when already complete - Add return after fail-fast to prevent fall-through to getResult() - Add _isComplete guard in RuntimeOrchestrationContext.resume() to prevent attempting to resume a finished generator Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes a crash in the core task-composition logic (whenAll) by making WhenAllTask resilient to child completions that arrive after the composite has already fail-fast completed, and by preventing the runtime from trying to resume an already-finished orchestrator generator.
Changes:
- Update
WhenAllTask.onChildCompleted()to ignore completions after completion, and to return immediately after fail-fast to prevent fall-through into result collection. - Add an
_isCompleteguard inRuntimeOrchestrationContext.resume()to avoid resuming finished orchestrations. - Add regression tests covering fail-fast + late completions and the “last completion is the failing one” scenario.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/durabletask-js/src/task/when-all-task.ts | Prevents fail-fast whenAll from throwing on later child completions and avoids fall-through into getResult() after a failure. |
| packages/durabletask-js/src/worker/runtime-orchestration-context.ts | Prevents attempts to resume a generator after orchestration completion. |
| packages/durabletask-js/test/orchestration_executor.spec.ts | Adds targeted regression coverage for whenAll fail-fast edge cases and caught-failure behavior. |
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.
Fix #120
WhenAllTask.onChildCompleted() had two bugs:
Threw 'Task is already completed' when a child completed after the WhenAllTask had already failed via fail-fast. This crashed orchestrations when multiple activities were in a WhenAll and one failed while others completed in the same or subsequent event batch.
Fell through from the fail-fast block to the result-collection block when the failing task was the last child to complete, causing getResult() to throw on the failed task.
Fixes:
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