Skip to content

Commit 70a6c4c

Browse files
committed
Attempt to fix race condition between cliManager and secretsManager setting the session token
1 parent 0ef2322 commit 70a6c4c

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
@@ -198,13 +198,13 @@ export class Commands {
198198
this.restClient.setHost(url);
199199
this.restClient.setSessionToken(res.token);
200200

201+
// Store on disk to be used by the cli.
202+
await this.cliManager.configure(label, url, res.token);
203+
201204
// Store these to be used in later sessions.
202205
await this.mementoManager.setUrl(url);
203206
await this.secretsManager.setSessionToken(res.token);
204207

205-
// Store on disk to be used by the cli.
206-
await this.cliManager.configure(label, url, res.token);
207-
208208
// These contexts control various menu items and the sidebar.
209209
await vscode.commands.executeCommand(
210210
"setContext",

src/extension.ts

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

159-
// Store on disk to be used by the cli.
160-
await cliManager.configure(toSafeHost(url), url, token);
161-
162163
vscode.commands.executeCommand(
163164
"coder.open",
164165
owner,

0 commit comments

Comments
 (0)