Remove dead continuedAsNew code after do-while loop#1304
Open
Remove dead continuedAsNew code after do-while loop#1304
Conversation
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
Contributor
There was a problem hiding this comment.
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
continuedAsNewandcontinuedAsNewMessagevariables to prevent their use outside the loop where they would always have constant values - Simplified the
CompleteTaskOrchestrationWorkItemAsyncmethod call by removing redundant null checks and passing concrete values instead of conditional expressions - Removed the redundant
continuedAsNewcondition from the return statement
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
The
do...while (continuedAsNew)loop inOnProcessWorkItemAsynconly exits whencontinuedAsNewisfalse. This means all references tocontinuedAsNewandcontinuedAsNewMessageafter the loop are dead code:continuedAsNew ? null : messagesToSendalways evaluate tomessagesToSend(same fortimerMessages).continuedAsNewMessageis alwaysnullafter the loop (it's only assigned whencontinuedAsNewistrue, which causes another loop iteration).continuedAsNewin the return statement is alwaysfalse.This code became dead ~7 years ago in #251, so it shouldn't be reflective of any recent change/regression.
Changes
continuedAsNewto just around the do-while loopcontinuedAsNewMessagedeclaration inside the loop bodyCompleteTaskOrchestrationWorkItemAsynccall argumentscontinuedAsNewfrom the return expressionTesting