Skip to content

Comments

Remove dead continuedAsNew code after do-while loop#1304

Open
cgillum wants to merge 1 commit intomainfrom
cgillum/remove-dead-continuedAsNew-code
Open

Remove dead continuedAsNew code after do-while loop#1304
cgillum wants to merge 1 commit intomainfrom
cgillum/remove-dead-continuedAsNew-code

Conversation

@cgillum
Copy link
Member

@cgillum cgillum commented Feb 24, 2026

Summary

The do...while (continuedAsNew) loop in OnProcessWorkItemAsync only exits when continuedAsNew is false. This means all references to continuedAsNew and continuedAsNewMessage after the loop are dead code:

  • The ternary checks continuedAsNew ? null : messagesToSend always evaluate to messagesToSend (same for timerMessages).
  • continuedAsNewMessage is always null after the loop (it's only assigned when continuedAsNew is true, which causes another loop iteration).
  • continuedAsNew in the return statement is always false.

This code became dead ~7 years ago in #251, so it shouldn't be reflective of any recent change/regression.

Changes

  • Narrowed the scope of continuedAsNew to just around the do-while loop
  • Moved continuedAsNewMessage declaration inside the loop body
  • Simplified the CompleteTaskOrchestrationWorkItemAsync call arguments
  • Removed continuedAsNew from the return expression

Testing

  • Build passes
  • All 176 DurableTask.Core.Tests pass (82 net48 + 94 net6.0)

The do-while loop in OnProcessWorkItemAsync exits only when continuedAsNew
is false. This means all references to continuedAsNew and continuedAsNewMessage
after the loop are dead code:

- The ternary checks 'continuedAsNew ? null : messagesToSend' always evaluate
  to messagesToSend (same for timerMessages).
- continuedAsNewMessage is always null (only set when continuedAsNew is true,
  which causes the loop to continue).
- 'continuedAsNew' in the return statement is always false.

This change:
- Narrows the scope of continuedAsNew to just around the do-while loop
- Moves continuedAsNewMessage declaration inside the loop body
- Simplifies the CompleteTaskOrchestrationWorkItemAsync call arguments
- Removes continuedAsNew from the return expression
Copilot AI review requested due to automatic review settings February 24, 2026 01:16
@cgillum cgillum requested a review from sophiatev February 24, 2026 01:17
Copy link
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 removes dead code related to continuedAsNew orchestration handling after a do-while loop in TaskOrchestrationDispatcher.cs. The do-while loop only exits when continuedAsNew is false, making all references to continuedAsNew and continuedAsNewMessage after the loop dead code that can be safely removed.

Changes:

  • Narrowed the scope of continuedAsNew and continuedAsNewMessage variables to prevent their use outside the loop where they would always have constant values
  • Simplified the CompleteTaskOrchestrationWorkItemAsync method call by removing redundant null checks and passing concrete values instead of conditional expressions
  • Removed the redundant continuedAsNew condition from the return statement

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

1 participant