fix: await abortTask in cancelTask to prevent content loss

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
This commit is contained in:
Roo Code 2025-12-15 15:16:28 +00:00
parent 1d4fc52485
commit b00bf19c86

View file

@ -2730,8 +2730,9 @@ export class ClineProvider
// This ensures the stream fails quickly rather than waiting for network timeout
task.cancelCurrentRequest()
// Begin abort (non-blocking)
task.abortTask()
// Begin abort and wait for messages to be saved to disk
// This ensures history is properly persisted before rehydration
await task.abortTask()
// Immediately mark the original instance as abandoned to prevent any residual activity
task.abandoned = true