Skip to content

Commit e6adda7

Browse files
authored
fix(amazonq): "Failed to run: refreshConnectionCallback" #5205
Problem: command sometimes shows an error during teardown: Failed to run command: aws.amazonq.refreshConnectionCallback: Cannot read properties of undefined (reading 'scopes') Solution: There may be a race somewhere, when we update the connections list. To mitigate, handle undefined AwsConnection.
1 parent a05dd40 commit e6adda7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,8 @@ export class AuthUtil {
442442
* a connection if it has some CW scopes.
443443
*/
444444
findMinimalQConnection(connections: AwsConnection[]): AwsConnection | undefined {
445-
const hasQScopes = (c: AwsConnection) => codeWhispererCoreScopes.every(s => c.scopes?.includes(s))
446-
const score = (c: AwsConnection) => Number(hasQScopes(c)) * 10 + Number(c.state === 'valid')
445+
const hasQScopes = (c?: AwsConnection) => codeWhispererCoreScopes.every(s => !!c?.scopes?.includes(s))
446+
const score = (c?: AwsConnection) => Number(hasQScopes(c)) * 10 + Number(c?.state === 'valid')
447447
connections.sort(function (a, b) {
448448
return score(b) - score(a)
449449
})

0 commit comments

Comments
 (0)