Skip to content

Commit ac37546

Browse files
committed
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.
1 parent 6e5bc31 commit ac37546

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

packages/core/src/amazonq/auth/controller.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6+
import { getLogger } from '../../shared/logger/logger'
67
import { reconnect } from '../../codewhisperer/commands/basicCommands'
78
import { amazonQChatSource } from '../../codewhisperer/commands/types'
89
import { focusAmazonQPanel } from '../../codewhispererChat/commands/registerCommands'
@@ -27,7 +28,9 @@ export class AuthController {
2728
}
2829

2930
private handleFullAuth() {
30-
void focusAmazonQPanel.execute(placeholder, 'amazonQChat')
31+
focusAmazonQPanel.execute(placeholder, 'amazonQChat').catch((e) => {
32+
getLogger().error('focusAmazonQPanel failed: %s', e)
33+
})
3134
}
3235

3336
private handleReAuth() {

packages/core/src/codewhisperer/commands/basicCommands.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,9 @@ export const notifyNewCustomizationsCmd = Commands.declare(
405405
function focusQAfterDelay() {
406406
// this command won't work without a small delay after install
407407
globals.clock.setTimeout(() => {
408-
void focusAmazonQPanel.execute(placeholder, 'startDelay')
408+
focusAmazonQPanel.execute(placeholder, 'startDelay').catch((e) => {
409+
getLogger().error('focusAmazonQPanel failed: %s', e)
410+
})
409411
}, 1000)
410412
}
411413

@@ -597,7 +599,10 @@ export const signoutCodeWhisperer = Commands.declare(
597599
(auth: AuthUtil) => async (_: VsCodeCommandArg, source: CodeWhispererSource) => {
598600
await auth.secondaryAuth.deleteConnection()
599601
SecurityIssueTreeViewProvider.instance.refresh()
600-
return focusAmazonQPanel.execute(placeholder, source)
602+
return focusAmazonQPanel.execute(placeholder, source).catch((e) => {
603+
getLogger().error('focusAmazonQPanel failed: %s', e)
604+
return undefined
605+
})
601606
}
602607
)
603608

packages/core/src/codewhisperer/ui/codeWhispererNodes.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { AuthUtil } from '../util/authUtil'
2828
import { submitFeedback } from '../../feedback/vue/submitFeedback'
2929
import { focusAmazonQPanel } from '../../codewhispererChat/commands/registerCommands'
3030
import { isWeb } from '../../shared/extensionGlobals'
31+
import { getLogger } from '../../shared'
3132

3233
export function createAutoSuggestions(running: boolean): DataQuickPickItem<'autoSuggestions'> {
3334
const labelResume = localize('AWS.codewhisperer.resumeCodeWhispererNode.label', 'Resume Auto-Suggestions')
@@ -250,7 +251,10 @@ export function switchToAmazonQNode(): DataQuickPickItem<'openChatPanel'> {
250251
data: 'openChatPanel',
251252
label: 'Open Chat Panel',
252253
iconPath: getIcon('vscode-comment'),
253-
onClick: () => focusAmazonQPanel.execute(placeholder, 'codewhispererQuickPick'),
254+
onClick: () =>
255+
focusAmazonQPanel.execute(placeholder, 'codewhispererQuickPick').catch((e) => {
256+
getLogger().error('focusAmazonQPanel failed: %s', e)
257+
}),
254258
}
255259
}
256260

@@ -259,7 +263,9 @@ export function createSignIn(): DataQuickPickItem<'signIn'> {
259263
const icon = getIcon('vscode-account')
260264

261265
let onClick = () => {
262-
void focusAmazonQPanel.execute(placeholder, 'codewhispererQuickPick')
266+
focusAmazonQPanel.execute(placeholder, 'codewhispererQuickPick').catch((e) => {
267+
getLogger().error('focusAmazonQPanel failed: %s', e)
268+
})
263269
}
264270
if (isWeb()) {
265271
// TODO: nkomonen, call a Command instead

packages/core/src/codewhisperer/util/authUtil.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,9 @@ export class AuthUtil {
267267
} catch (err) {
268268
if (err instanceof ProfileNotFoundError) {
269269
// Expected that connection would be deleted by conn.getToken()
270-
void focusAmazonQPanel.execute(placeholder, 'profileNotFoundSignout')
270+
focusAmazonQPanel.execute(placeholder, 'profileNotFoundSignout').catch((e) => {
271+
getLogger().error('focusAmazonQPanel failed: %s', e)
272+
})
271273
}
272274
throw err
273275
}

0 commit comments

Comments
 (0)