Skip to content

Commit 009258c

Browse files
authored
fix(amazonq): show empty response when token was cancelled (#7128)
## Problem in some cases when tools are cancelled on the flare side, a cancellation error will hit our catch and log "❌ Error: Request failed to complete" ## Solution when the token was canceled don't log anything --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 6782509 commit 009258c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/amazonq/src/lsp/chat/messages.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,16 @@ export function registerMessageListeners(
254254
} catch (e) {
255255
languageClient.info(`Error occurred during chat request: ${e}`)
256256
// Use the last partial result if available, append error message
257+
let body = ''
258+
if (!cancellationToken.token.isCancellationRequested) {
259+
body = lastPartialResult?.body
260+
? `${lastPartialResult.body}\n\n ❌ Error: Request failed to complete`
261+
: '❌ An error occurred while processing your request'
262+
}
263+
257264
const errorResult: ChatResult = {
258265
...lastPartialResult,
259-
body: lastPartialResult?.body
260-
? `${lastPartialResult.body}\n\n ❌ Error: Request failed to complete`
261-
: '❌ An error occurred while processing your request',
266+
body,
262267
}
263268

264269
await handleCompleteResult<ChatResult>(

0 commit comments

Comments
 (0)