From b90b95d4d3ae4d47342518a499650543f4e1179e Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 29 May 2025 14:51:36 -0400 Subject: [PATCH] fix: "rejected promise not handled" Problem: rejected promise not handled within 1 second: Error: command 'aws.amazonq.focusChat' not found Solution: Don't use `void` to ignore rejected promises. --- packages/amazonq/src/app/chat/activation.ts | 6 ++++-- packages/amazonq/src/extension.ts | 4 +++- packages/core/src/amazonq/auth/controller.ts | 5 ++++- .../core/src/codewhisperer/commands/basicCommands.ts | 9 +++++++-- .../core/src/codewhisperer/ui/codeWhispererNodes.ts | 10 ++++++++-- packages/core/src/codewhisperer/util/authUtil.ts | 4 +++- 6 files changed, 29 insertions(+), 9 deletions(-) diff --git a/packages/amazonq/src/app/chat/activation.ts b/packages/amazonq/src/app/chat/activation.ts index af48bc65e05..659115d4256 100644 --- a/packages/amazonq/src/app/chat/activation.ts +++ b/packages/amazonq/src/app/chat/activation.ts @@ -7,7 +7,7 @@ import * as vscode from 'vscode' import { ExtensionContext } from 'vscode' import { telemetry } from 'aws-core-vscode/telemetry' import { AuthUtil } from 'aws-core-vscode/codewhisperer' -import { Commands, placeholder } from 'aws-core-vscode/shared' +import { Commands, getLogger, placeholder } from 'aws-core-vscode/shared' import * as amazonq from 'aws-core-vscode/amazonq' export async function activate(context: ExtensionContext) { @@ -67,7 +67,9 @@ async function setupAuthNotification() { const selection = await vscode.window.showWarningMessage('Start using Amazon Q', buttonAction) if (selection === buttonAction) { - void amazonq.focusAmazonQPanel.execute(placeholder, source) + amazonq.focusAmazonQPanel.execute(placeholder, source).catch((e) => { + getLogger().error('focusAmazonQPanel failed: %s', e) + }) } } } diff --git a/packages/amazonq/src/extension.ts b/packages/amazonq/src/extension.ts index 45641b37440..e5e0700614d 100644 --- a/packages/amazonq/src/extension.ts +++ b/packages/amazonq/src/extension.ts @@ -166,7 +166,9 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is // Give time for the extension to finish initializing. globals.clock.setTimeout(async () => { CommonAuthWebview.authSource = ExtStartUpSources.firstStartUp - void focusAmazonQPanel.execute(placeholder, ExtStartUpSources.firstStartUp) + focusAmazonQPanel.execute(placeholder, ExtStartUpSources.firstStartUp).catch((e) => { + getLogger().error('focusAmazonQPanel failed: %s', e) + }) }, 1000) } diff --git a/packages/core/src/amazonq/auth/controller.ts b/packages/core/src/amazonq/auth/controller.ts index 9cc09ef17cb..5b9772d686a 100644 --- a/packages/core/src/amazonq/auth/controller.ts +++ b/packages/core/src/amazonq/auth/controller.ts @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import { getLogger } from '../../shared/logger/logger' import { reconnect } from '../../codewhisperer/commands/basicCommands' import { amazonQChatSource } from '../../codewhisperer/commands/types' import { focusAmazonQPanel } from '../../codewhispererChat/commands/registerCommands' @@ -27,7 +28,9 @@ export class AuthController { } private handleFullAuth() { - void focusAmazonQPanel.execute(placeholder, 'amazonQChat') + focusAmazonQPanel.execute(placeholder, 'amazonQChat').catch((e) => { + getLogger().error('focusAmazonQPanel failed: %s', e) + }) } private handleReAuth() { diff --git a/packages/core/src/codewhisperer/commands/basicCommands.ts b/packages/core/src/codewhisperer/commands/basicCommands.ts index 7fe6078a1d7..a24c6ade704 100644 --- a/packages/core/src/codewhisperer/commands/basicCommands.ts +++ b/packages/core/src/codewhisperer/commands/basicCommands.ts @@ -405,7 +405,9 @@ export const notifyNewCustomizationsCmd = Commands.declare( function focusQAfterDelay() { // this command won't work without a small delay after install globals.clock.setTimeout(() => { - void focusAmazonQPanel.execute(placeholder, 'startDelay') + focusAmazonQPanel.execute(placeholder, 'startDelay').catch((e) => { + getLogger().error('focusAmazonQPanel failed: %s', e) + }) }, 1000) } @@ -597,7 +599,10 @@ export const signoutCodeWhisperer = Commands.declare( (auth: AuthUtil) => async (_: VsCodeCommandArg, source: CodeWhispererSource) => { await auth.secondaryAuth.deleteConnection() SecurityIssueTreeViewProvider.instance.refresh() - return focusAmazonQPanel.execute(placeholder, source) + return focusAmazonQPanel.execute(placeholder, source).catch((e) => { + getLogger().error('focusAmazonQPanel failed: %s', e) + return undefined + }) } ) diff --git a/packages/core/src/codewhisperer/ui/codeWhispererNodes.ts b/packages/core/src/codewhisperer/ui/codeWhispererNodes.ts index c3e46bdc78e..f317a20a573 100644 --- a/packages/core/src/codewhisperer/ui/codeWhispererNodes.ts +++ b/packages/core/src/codewhisperer/ui/codeWhispererNodes.ts @@ -28,6 +28,7 @@ import { AuthUtil } from '../util/authUtil' import { submitFeedback } from '../../feedback/vue/submitFeedback' import { focusAmazonQPanel } from '../../codewhispererChat/commands/registerCommands' import { isWeb } from '../../shared/extensionGlobals' +import { getLogger } from '../../shared/logger/logger' export function createAutoSuggestions(running: boolean): DataQuickPickItem<'autoSuggestions'> { const labelResume = localize('AWS.codewhisperer.resumeCodeWhispererNode.label', 'Resume Auto-Suggestions') @@ -238,7 +239,10 @@ export function switchToAmazonQNode(): DataQuickPickItem<'openChatPanel'> { data: 'openChatPanel', label: 'Open Chat Panel', iconPath: getIcon('vscode-comment'), - onClick: () => focusAmazonQPanel.execute(placeholder, 'codewhispererQuickPick'), + onClick: () => + focusAmazonQPanel.execute(placeholder, 'codewhispererQuickPick').catch((e) => { + getLogger().error('focusAmazonQPanel failed: %s', e) + }), } } @@ -247,7 +251,9 @@ export function createSignIn(): DataQuickPickItem<'signIn'> { const icon = getIcon('vscode-account') let onClick = () => { - void focusAmazonQPanel.execute(placeholder, 'codewhispererQuickPick') + focusAmazonQPanel.execute(placeholder, 'codewhispererQuickPick').catch((e) => { + getLogger().error('focusAmazonQPanel failed: %s', e) + }) } if (isWeb()) { // TODO: nkomonen, call a Command instead diff --git a/packages/core/src/codewhisperer/util/authUtil.ts b/packages/core/src/codewhisperer/util/authUtil.ts index 10acbe16424..e5177e7b578 100644 --- a/packages/core/src/codewhisperer/util/authUtil.ts +++ b/packages/core/src/codewhisperer/util/authUtil.ts @@ -267,7 +267,9 @@ export class AuthUtil { } catch (err) { if (err instanceof ProfileNotFoundError) { // Expected that connection would be deleted by conn.getToken() - void focusAmazonQPanel.execute(placeholder, 'profileNotFoundSignout') + focusAmazonQPanel.execute(placeholder, 'profileNotFoundSignout').catch((e) => { + getLogger().error('focusAmazonQPanel failed: %s', e) + }) } throw err }