Skip to content

fix: guard setFailed after orchestration completion#267

Merged
YunchuWang merged 1 commit into
mainfrom
copilot-finds/bug/fix-setfailed-missing-iscomplete-guard
Jun 12, 2026
Merged

fix: guard setFailed after orchestration completion#267
YunchuWang merged 1 commit into
mainfrom
copilot-finds/bug/fix-setfailed-missing-iscomplete-guard

Conversation

@YunchuWang

Copy link
Copy Markdown
Member

Summary

Fixes #237

Copilot AI review requested due to automatic review settings June 11, 2026 20:54
…after setComplete()

When a NonDeterminismError occurs during replay after the orchestrator
generator has already finished (and setComplete was called), setFailed()
now removes the previously added completeOrchestration action before
adding the FAILED action. This ensures exactly one completion action is
returned to the sidecar.

Previously, setFailed() would unconditionally add a second completion
action, resulting in an invalid response with both COMPLETED and FAILED
terminal actions.

Fixes #237

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@YunchuWang
YunchuWang force-pushed the copilot-finds/bug/fix-setfailed-missing-iscomplete-guard branch from 02fb1b6 to 6f6ba65 Compare June 11, 2026 20:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 worker-side edge case where RuntimeOrchestrationContext.setFailed() could emit a second terminal completeOrchestration action after the orchestration had already been completed, resulting in an invalid “two terminal actions” response to the sidecar. It aligns setFailed() behavior with the existing double-completion safeguards in the completion paths.

Changes:

  • Remove any previously queued completeOrchestration action from _pendingActions when setFailed() is invoked after completion.
  • Add a regression test that simulates replay-time non-determinism leading to setComplete() followed by setFailed().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/durabletask-js/src/worker/runtime-orchestration-context.ts Ensures setFailed() replaces (rather than duplicates) an existing completion action in _pendingActions.
packages/durabletask-js/test/orchestration_executor.spec.ts Adds a test covering the replay/non-determinism scenario that previously produced duplicate completion actions.

@YunchuWang
YunchuWang merged commit d690efe into main Jun 12, 2026
28 checks passed
@YunchuWang
YunchuWang deleted the copilot-finds/bug/fix-setfailed-missing-iscomplete-guard branch June 12, 2026 21:25
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: setFailed() produces duplicate completion actions when called after setComplete()

4 participants