Skip to content

Commit

Permalink
Recreate REST client after starting a workspace (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronlehmann authored Feb 4, 2025
1 parent 9253a22 commit 242a517
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Recreate REST client after starting a workspace to ensure fresh TLS certificates.

## [v1.3.10](https://github.com/coder/vscode-coder/releases/tag/v1.3.9) (2025-01-17)

- Fix bug where checking for overridden properties incorrectly converted host name pattern to regular expression.
Expand Down
21 changes: 11 additions & 10 deletions src/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ export class Remote {
label: string,
binPath: string,
): Promise<Workspace | undefined> {
// Maybe already running?
if (workspace.latest_build.status === "running") {
return workspace
}

const workspaceName = `${workspace.owner_name}/${workspace.name}`

// A terminal will be used to stream the build, if one is necessary.
Expand Down Expand Up @@ -320,13 +315,19 @@ export class Remote {
disposables.push(this.registerLabelFormatter(remoteAuthority, workspace.owner_name, workspace.name))

// If the workspace is not in a running state, try to get it running.
const updatedWorkspace = await this.maybeWaitForRunning(workspaceRestClient, workspace, parts.label, binaryPath)
if (!updatedWorkspace) {
// User declined to start the workspace.
await this.closeRemote()
if (workspace.latest_build.status !== "running") {
if (!(await this.maybeWaitForRunning(workspaceRestClient, workspace, parts.label, binaryPath))) {
// User declined to start the workspace.
await this.closeRemote()
} else {
// Start over with a fresh REST client because we may have waited an
// indeterminate amount amount of time for confirmation to start the
// workspace.
await this.setup(remoteAuthority)
}
return
}
this.commands.workspace = workspace = updatedWorkspace
this.commands.workspace = workspace

// Pick an agent.
this.storage.writeToCoderOutputChannel(`Finding agent for ${workspaceName}...`)
Expand Down

0 comments on commit 242a517

Please sign in to comment.