-
Notifications
You must be signed in to change notification settings - Fork 2.4k
hotfix: serialize resumptions to prevent cancel+restore race condition #9025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fixes concurrent resumption flows that can cause 'two instances' behavior when: - UI cancel schedules presentResumableAsk via setImmediate - Webview checkpoint restore calls cancel then restore - Both flows reset abort flags and call into task loop simultaneously Changes: - Add suppressResumeAsk flag in ClineProvider to gate scheduling during transactions - Add resumeAskScheduledForTaskId dedupe to prevent multiple scheduled asks per task - Wrap checkpoint restore flow with suppression to serialize with cancel path - Enhanced scheduling guards: re-check suppression, verify task not switched/abandoned - Unit tests for gating behavior and deduplication Addresses PR #8986 recommendations for provider-level resumption serialization.
|
Reviewed the race condition fix. Found 1 issue that needs to be addressed:
Mention @roomote in a comment to trigger your PR Fixer agent and make changes to this pull request. |
| } finally { | ||
| // End transaction and post consolidated state | ||
| await provider.endStateTransaction() | ||
| provider.setSuppressResumeAsk(false) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If endStateTransaction() throws an exception, setSuppressResumeAsk(false) on line 1057 won't execute, leaving the suppression flag permanently set to true. This would prevent all future resume asks from being scheduled until VS Code is restarted. Nest the cleanup in a second try-finally block to guarantee the flag is always reset:
} finally {
try {
await provider.endStateTransaction()
} finally {
provider.setSuppressResumeAsk(false)
}
}Fix it with Roo Code or mention @roomote and request a fix.
|
Reviewing your PR now. Feedback coming soon! Mention @roomote in a comment to trigger your PR Fixer agent and make changes to this pull request. |
Fixes concurrent resumption flows that can cause two instances behavior when UI cancel schedules presentResumableAsk via setImmediate and webview checkpoint restore calls cancel then restore. Both flows can reset abort flags and call into task loop simultaneously.
Solution: Add suppressResumeAsk flag in ClineProvider to gate scheduling during transactions, plus resumeAskScheduledForTaskId dedupe to prevent multiple asks per task. Wrap checkpoint restore flow with suppression to serialize with cancel path.
Testing: Extended existing tests and added new test for checkpoint restore suppression. All 10 tests across 4 files pass.
Related to: #8986
Addresses PR 8986 recommendations for provider-level resumption serialization.
Important
Introduces suppression and deduplication in
ClineProviderto prevent concurrent task resumptions, with tests added for validation.suppressResumeAskflag andresumeAskScheduledForTaskIdinClineProviderto prevent concurrent resumptions.webviewMessageHandler.tswith suppression to serialize with cancel path.cancelTask()inClineProviderto checksuppressResumeAskand deduplicatepresentResumableAskscheduling.webviewMessageHandler()to setsuppressResumeAskduring checkpoint restore.ClineProvider.cancelTask.present-ask.spec.tsfor suppression and deduplication logic.webviewMessageHandler.resume-gating.spec.tsto test suppression during checkpoint restore.This description was created by
for 7827cb7. You can customize this summary. It will automatically update as commits are pushed.