mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
fix: resolve API failures being misclassified as user cancellations (#5427)
- Fixed error handling logic in Task.ts to check abort status before calling abortTask() - Ensures API failures show proper error messages instead of 'API Request Cancelled' - Addresses issue where all API failures on Windows were incorrectly categorized as user cancellations
This commit is contained in:
parent
5b1ca51ec0
commit
df2b777fde
1 changed files with 12 additions and 9 deletions
|
|
@ -1422,20 +1422,21 @@ export class Task extends EventEmitter<ClineEvents> {
|
|||
// Cline instance to finish aborting (error is thrown here when
|
||||
// any function in the for loop throws due to this.abort).
|
||||
if (!this.abandoned) {
|
||||
// Check if this was a user-initiated cancellation BEFORE calling abortTask()
|
||||
// If this.abort is true, it means the user clicked cancel, so we should
|
||||
// treat this as "user_cancelled" rather than "streaming_failed"
|
||||
const wasUserCancelled = this.abort
|
||||
const cancelReason = wasUserCancelled ? "user_cancelled" : "streaming_failed"
|
||||
const streamingFailedMessage = wasUserCancelled
|
||||
? undefined
|
||||
: (error.message ?? JSON.stringify(serializeError(error), null, 2))
|
||||
|
||||
// If the stream failed, there's various states the task
|
||||
// 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
|
||||
// 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))
|
||||
|
||||
await abortStream(cancelReason, streamingFailedMessage)
|
||||
|
||||
const history = await provider?.getTaskWithId(this.taskId)
|
||||
|
|
@ -1716,7 +1717,9 @@ export class Task extends EventEmitter<ClineEvents> {
|
|||
|
||||
const contextWindow = modelInfo.contextWindow
|
||||
|
||||
const currentProfileId = state?.listApiConfigMeta.find((profile) => profile.name === state?.currentApiConfigName)?.id ?? "default";
|
||||
const currentProfileId =
|
||||
state?.listApiConfigMeta.find((profile) => profile.name === state?.currentApiConfigName)?.id ??
|
||||
"default"
|
||||
|
||||
const truncateResult = await truncateConversationIfNeeded({
|
||||
messages: this.apiConversationHistory,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue