fix: prevent "Current ask promise was ignored" error from displaying to users

- Changed synchronous throw statements to Promise.reject() in Task.ask() method
- This allows .catch() handlers in writeToFileTool to properly suppress expected errors
- Fixes issue #6443 where users saw error messages during file writing after diff edits
- All existing tests continue to pass
This commit is contained in:
Roo Code 2025-07-30 16:10:25 +00:00
parent f3d2504117
commit 49a9347e60

View file

@ -637,14 +637,14 @@ export class Task extends EventEmitter<ClineEvents> {
// saves, and only post parts of partial message instead of
// whole array in new listener.
this.updateClineMessage(lastMessage)
throw new Error("Current ask promise was ignored (#1)")
return Promise.reject(new Error("Current ask promise was ignored (#1)"))
} else {
// This is a new partial message, so add it with partial
// state.
askTs = Date.now()
this.lastMessageTs = askTs
await this.addToClineMessages({ ts: askTs, type: "ask", ask: type, text, partial, isProtected })
throw new Error("Current ask promise was ignored (#2)")
return Promise.reject(new Error("Current ask promise was ignored (#2)"))
}
} else {
if (isUpdatingPreviousPartial) {
@ -699,7 +699,7 @@ export class Task extends EventEmitter<ClineEvents> {
// Could happen if we send multiple asks in a row i.e. with
// command_output. It's important that when we know an ask could
// fail, it is handled gracefully.
throw new Error("Current ask promise was ignored")
return Promise.reject(new Error("Current ask promise was ignored"))
}
const result = { response: this.askResponse!, text: this.askResponseText, images: this.askResponseImages }