From 9957d53508f1d9341bd58830d1d5904fbaa0e8ce Mon Sep 17 00:00:00 2001 From: Roo Code Date: Mon, 21 Jul 2025 16:57:21 +0000 Subject: [PATCH 1/2] fix: check abort flag before calling abortTask to properly distinguish API failures - Check if this.abort is true BEFORE calling abortTask() in the error handler - This allows proper distinction between user-initiated cancellations (where abort was already true) and actual API failures (where abort was false) - Fixes issue #5427 where all API failures were incorrectly reported as "API Request Cancelled" --- src/core/task/Task.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/task/Task.ts b/src/core/task/Task.ts index 53b8ef5b87d..01906f9cdac 100644 --- a/src/core/task/Task.ts +++ b/src/core/task/Task.ts @@ -1442,16 +1442,18 @@ export class Task extends EventEmitter { // could be in (i.e. could have streamed some tools the user // may have executed), so we just resort to replicating a // cancel task. - this.abortTask() - // Check if this was a user-initiated cancellation - // If this.abort is true, it means the user clicked cancel, so we should + // Check if this was a user-initiated cancellation BEFORE calling abortTask + // If this.abort is already true, it means the user clicked cancel, so we should // treat this as "user_cancelled" rather than "streaming_failed" const cancelReason = this.abort ? "user_cancelled" : "streaming_failed" const streamingFailedMessage = this.abort ? undefined : (error.message ?? JSON.stringify(serializeError(error), null, 2)) + // Now call abortTask after determining the cancel reason + this.abortTask() + await abortStream(cancelReason, streamingFailedMessage) const history = await provider?.getTaskWithId(this.taskId) From 1dd92ee4c1b1cdcfd066020eb08daad71c31b06f Mon Sep 17 00:00:00 2001 From: Daniel <57051444+daniel-lxs@users.noreply.github.com> Date: Mon, 21 Jul 2025 13:04:28 -0500 Subject: [PATCH 2/2] Apply suggestion from @ellipsis-dev[bot] Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> --- src/core/task/Task.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/task/Task.ts b/src/core/task/Task.ts index 01906f9cdac..ccd24b7d71c 100644 --- a/src/core/task/Task.ts +++ b/src/core/task/Task.ts @@ -1452,7 +1452,7 @@ export class Task extends EventEmitter { : (error.message ?? JSON.stringify(serializeError(error), null, 2)) // Now call abortTask after determining the cancel reason - this.abortTask() + await this.abortTask() await abortStream(cancelReason, streamingFailedMessage)