Skip to content

Commit 2c9d505

Browse files
authored
fix(amazonq): update the bearer token in the language server every 5 minutes (aws#6793)
## Problem - When the bearer token updates in the background we never re-notify the language server ## Solution - update it every 5 minutes as a hack to unblock the pentest --- - 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 280d66b commit 2c9d505

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

packages/amazonq/src/lsp/client.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@ import { registerInlineCompletion } from '../app/inline/completion'
1111
import { AmazonQLspAuth, encryptionKey, notificationTypes } from './auth'
1212
import { AuthUtil } from 'aws-core-vscode/codewhisperer'
1313
import { ConnectionMetadata } from '@aws/language-server-runtimes/protocol'
14-
import { ResourcePaths, Settings, oidcClientName, createServerOptions, globals } from 'aws-core-vscode/shared'
14+
import {
15+
ResourcePaths,
16+
Settings,
17+
oidcClientName,
18+
createServerOptions,
19+
globals,
20+
getLogger,
21+
} from 'aws-core-vscode/shared'
1522

1623
const localize = nls.loadMessageBundle()
1724

@@ -100,6 +107,16 @@ export async function startLanguageServer(extensionContext: vscode.ExtensionCont
100107
}
101108
})
102109

110+
// Temporary code for pen test. Will be removed when we switch to the real flare auth
111+
const authInterval = setInterval(async () => {
112+
try {
113+
await auth.init()
114+
} catch (e) {
115+
getLogger('amazonqLsp').error('Unable to update bearer token: %s', (e as Error).message)
116+
clearInterval(authInterval)
117+
}
118+
}, 300000) // every 5 minutes
119+
103120
toDispose.push(
104121
AuthUtil.instance.auth.onDidChangeActiveConnection(async () => {
105122
await auth.init()

0 commit comments

Comments
 (0)