Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Dec 15, 2025

Related GitHub Issue

Closes: #10093

Description

This PR attempts to address Issue #10093 where canceling a task during an API request causes content loss.

Root Cause: In cancelTask(), task.abortTask() was called without await. The abortTask() method saves messages to disk asynchronously, but since it was not awaited, createTaskWithHistoryItem() would fetch the history before the messages were persisted.

Fix: Added await to the task.abortTask() call to ensure messages are properly saved to disk before attempting to rehydrate the task from history.

Test Procedure

  1. Ran existing tests:
    • ClineProvider.spec.ts - All 99 tests pass
    • ClineProvider.flicker-free-cancel.spec.ts - All 4 tests pass
  2. Manual testing steps:
    • Start a new task with any prompt
    • Wait for the API request to begin streaming
    • Click the "Cancel" button while streaming is in progress
    • Verify that the task retains conversation history up to the point of cancellation

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

N/A - This is a backend fix with no UI changes.

Documentation Updates

  • No documentation updates are required.

Additional Notes

Feedback and guidance are welcome.

When canceling a task during an API request, messages were being lost
because abortTask() was called without await. This caused the history
to be fetched before messages were saved to disk.

The fix adds await to the abortTask() call to ensure messages are
properly persisted before createTaskWithHistoryItem() attempts to
read them.

Fixes #10093
@roomote
Copy link
Contributor Author

roomote bot commented Dec 15, 2025

Rooviewer Clock   See task on Roo Cloud

Reviewed this PR - no issues found.

The fix correctly addresses the race condition in cancelTask() where messages weren't being persisted before rehydration. Adding await to task.abortTask() ensures saveClineMessages() completes before createTaskWithHistoryItem() reads from disk.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[BUG] "Cancel task during API request causes content loss"

3 participants