Skip to content

Commit 33a5736

Browse files
refactor: move auth restore to right after creating the instance
Signed-off-by: nkomonen-amazon <[email protected]>
1 parent 520acb0 commit 33a5736

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

packages/amazonq/src/lsp/activation.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ import vscode from 'vscode'
77
import { startLanguageServer } from './client'
88
import { AmazonQLspInstaller } from './lspInstaller'
99
import { lspSetupStage, ToolkitError, messages } from 'aws-core-vscode/shared'
10-
import { AuthUtil } from 'aws-core-vscode/codewhisperer'
1110

1211
export async function activate(ctx: vscode.ExtensionContext) {
1312
try {
1413
await lspSetupStage('all', async () => {
1514
const installResult = await new AmazonQLspInstaller().resolve()
1615
return await lspSetupStage('launch', () => startLanguageServer(ctx, installResult.resourcePaths))
1716
})
18-
await AuthUtil.instance.restore()
1917
} catch (err) {
2018
const e = err as ToolkitError
2119
void messages.showViewLogsMessage(`Failed to launch Amazon Q language server: ${e.message}`)

packages/amazonq/src/lsp/client.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,12 @@ export async function startLanguageServer(
175175
toDispose.push(disposable)
176176

177177
await client.onReady()
178+
179+
// IMPORTANT: This sets up Auth and must be called before anything attempts to use it
178180
AuthUtil.create(new auth2.LanguageClientAuth(client, clientId, encryptionKey))
181+
// Ideally this would be part of AuthUtil.create() as it restores the existing Auth connection, but we have some
182+
// future work which will need to delay this call
183+
await AuthUtil.instance.restore()
179184

180185
await postStartLanguageServer(client, resourcePaths, toDispose)
181186

0 commit comments

Comments
 (0)