Skip to content

Recreate REST client after starting a workspace #431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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