Skip to content

Commit a93b9f1

Browse files
authored
fix(codewhisperer): Add more debug logs for connection expiration (#3809)
* add more debug logs * add prefix codewhisperer to log debug * add change log
1 parent 193730f commit a93b9f1

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "CodeWhisperer: show \"Reconnect\" instead of \"Start\" for expired connections to make reconnecting easier"
4+
}

src/codewhisperer/explorer/codewhispererNode.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,13 @@ export class CodeWhispererNode implements RootNode {
6767
public getChildren() {
6868
const autoTriggerEnabled =
6969
globals.context.globalState.get<boolean>(CodeWhispererConstants.autoTriggerEnabledKey) || false
70-
70+
if (AuthUtil.instance.isConnectionExpired()) {
71+
return [createReconnectNode(), createLearnMore()]
72+
}
7173
if (!AuthUtil.instance.isConnected()) {
7274
return [createSsoSignIn(), createLearnMore()]
7375
}
74-
75-
if (AuthUtil.instance.isConnectionExpired()) {
76-
return [createReconnectNode(), createLearnMore()]
77-
} else if (this._showFreeTierLimitReachedNode) {
76+
if (this._showFreeTierLimitReachedNode) {
7877
if (isCloud9()) {
7978
return [createFreeTierLimitMetNode(), createOpenReferenceLogNode()]
8079
} else {

src/codewhisperer/util/authUtil.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
isSsoConnection,
2525
isBuilderIdConnection,
2626
} from '../../auth/connection'
27+
import { getLogger } from '../../shared/logger'
2728

2829
export const defaultCwScopes = [...ssoAccountAccessScopes, ...codewhispererScopes]
2930
export const awsBuilderIdSsoProfile = createBuilderIdProfile(defaultCwScopes)
@@ -181,15 +182,27 @@ export class AuthUtil {
181182
}
182183

183184
public isConnectionValid(): boolean {
184-
return this.conn !== undefined && !this.secondaryAuth.isConnectionExpired
185+
const connectionValid = this.conn !== undefined && !this.secondaryAuth.isConnectionExpired
186+
getLogger().debug(`codewhisperer: Connection is valid = ${connectionValid},
187+
connection is undefined = ${this.conn === undefined},
188+
secondaryAuth connection expired = ${this.secondaryAuth.isConnectionExpired}`)
189+
return connectionValid
185190
}
186191

187192
public isConnectionExpired(): boolean {
188-
return (
193+
const connectionExpired =
189194
this.secondaryAuth.isConnectionExpired &&
190195
this.conn !== undefined &&
191196
isValidCodeWhispererConnection(this.conn)
192-
)
197+
getLogger().debug(`codewhisperer: Connection expired = ${connectionExpired},
198+
secondaryAuth connection expired = ${this.secondaryAuth.isConnectionExpired},
199+
connection is undefined = ${this.conn === undefined}`)
200+
if (this.conn) {
201+
getLogger().debug(
202+
`codewhisperer: isValidCodeWhispererConnection = ${isValidCodeWhispererConnection(this.conn)}`
203+
)
204+
}
205+
return connectionExpired
193206
}
194207

195208
public async reauthenticate() {

0 commit comments

Comments
 (0)