Skip to content

Commit bbfb3d5

Browse files
committed
Attempt to fix race condition between cliManager and secretsManager setting the session token
1 parent 55c26a1 commit bbfb3d5

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/commands.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,13 @@ export class Commands {
211211
this.restClient.setHost(url);
212212
this.restClient.setSessionToken(res.token);
213213

214+
// Store on disk to be used by the cli.
215+
await this.cliManager.configure(label, url, res.token);
216+
214217
// Store these to be used in later sessions.
215218
await this.mementoManager.setUrl(url);
216219
await this.secretsManager.setSessionToken(res.token);
217220

218-
// Store on disk to be used by the cli.
219-
await this.cliManager.configure(label, url, res.token);
220-
221221
// These contexts control various menu items and the sidebar.
222222
await vscode.commands.executeCommand(
223223
"setContext",

src/extension.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,15 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
149149
const token = needToken(vscode.workspace.getConfiguration())
150150
? params.get("token")
151151
: (params.get("token") ?? "");
152+
153+
// Store on disk to be used by the cli.
154+
await cliManager.configure(toSafeHost(url), url, token);
155+
152156
if (token) {
153157
client.setSessionToken(token);
154158
await secretsManager.setSessionToken(token);
155159
}
156160

157-
// Store on disk to be used by the cli.
158-
await cliManager.configure(toSafeHost(url), url, token);
159-
160161
vscode.commands.executeCommand(
161162
"coder.open",
162163
owner,

0 commit comments

Comments
 (0)