Skip to content

fix: Add missing non-Task validation in generator failure recovery path#163

Merged
YunchuWang merged 3 commits into
mainfrom
copilot-finds/bug/fix-missing-non-task-validation-in-failure-path
Mar 11, 2026
Merged

fix: Add missing non-Task validation in generator failure recovery path#163
YunchuWang merged 3 commits into
mainfrom
copilot-finds/bug/fix-missing-non-task-validation-in-failure-path

Conversation

@YunchuWang
Copy link
Copy Markdown
Member

Summary

Add non-Task validation in the failure recovery path of
esume() to match the existing validation in the success path.

Closes #159

Problem

When an orchestrator catches a failed task exception and yields a non-Task value, the failure recovery path silently returns without error, leaving _previousTask pointing to the old failed task. The success path already correctly validates with hrow new Error('The orchestrator generator yielded a non-Task object').

Fix

Add the same validation error after the instanceof Task check in the failure recovery path.

… recovery path

When an orchestrator catches a failed task exception and then yields a
non-Task value, the success path in resume() correctly throws an error
('The orchestrator generator yielded a non-Task object'), but the failure
recovery path silently returns without updating _previousTask. This
leaves the orchestration context in a broken state where:

1. _previousTask still points to the old failed task
2. The next resume() call re-throws the same exception to the generator
3. The orchestration gets stuck or produces confusing errors

The fix adds the same non-Task validation to the failure recovery path,
making it consistent with the success path. Two new tests verify both
the error case and the normal recovery case.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 11, 2026 18:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug in the orchestration replay engine by making the generator “failure recovery” path validate yielded values the same way the “success” path already does, ensuring that yielding a non-Task after catching a task failure deterministically fails the orchestration (instead of silently returning in a broken state).

Changes:

  • Add missing non-Task validation in RuntimeOrchestrationContext.resume() when resuming via generator.throw(...).
  • Add Jest coverage for (a) yielding a non-Task after catching a failure and (b) yielding a valid recovery Task after catching a failure.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/durabletask-js/src/worker/runtime-orchestration-context.ts Adds the missing throw for non-Task yields in the failure recovery path of resume().
packages/durabletask-js/test/orchestration_executor.spec.ts Adds regression tests covering the failure-recovery yield validation behavior.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread packages/durabletask-js/test/orchestration_executor.spec.ts Outdated
@YunchuWang YunchuWang merged commit 5b58b2a into main Mar 11, 2026
28 checks passed
@YunchuWang YunchuWang deleted the copilot-finds/bug/fix-missing-non-task-validation-in-failure-path branch March 11, 2026 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[copilot-finds] Bug: Missing non-Task validation in generator failure recovery path

4 participants