Skip to content

fix: queue workspace updates as one build - #1115

Open
EhabY wants to merge 1 commit into
mainfrom
fix/1095-update-reconnect-race
Open

EhabY wants to merge 1 commit into
mainfrom
fix/1095-update-reconnect-race

Conversation

@EhabY

@EhabY EhabY commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Problem

coder update runs a stop build and then a start build. Between the two, the extension's own coder ssh reconnect autostarts the workspace on the old template version, so the update's start build is rejected:

stopped → starting   reason: ssh_connection
"A workspace build is already active"

The workspace restarts on the version it already had, and the extension logs a warning and connects anyway.

Changes

Deployment Update path
2.36 and later One stop build that carries the start in on_success, so nothing can take the slot in between
Before 2.36 Unchanged: coder update, or the REST API on CLIs before 2.24

The server owns the slot from the moment the stop build is posted, so a reconnect can no longer jump ahead of the update. template_version_id stays unset on the queued start, because pinning a follow-up build requires template update permission and the update targets the active version anyway. A workspace that is already stopped takes a lone start build, which can name the version.

While the queued build runs, the state machine follows it instead of starting the workspace itself, and it ignores monitor events from older builds.

On a failed update, a modal offers Connect Anyway instead of silently falling back to the old version. Declining aborts the connection.

Feature sets

FeatureSet becomes CliFeatureSet, and a new ServerFeatureSet keys the 2.36 check to the deployment version instead of the CLI's. The Tasks check moves there too, bounded to 2.29 through 2.34, the releases that serve /api/v2/tasks (coder/coder#20921 promoted it out of /api/experimental). Below 2.29 the panel used to show and then 404 on every poll.

Validation

pnpm lint, pnpm typecheck, pnpm format:check, and pnpm test (2,729 passed, 1 skipped, 185 files). No live SSH-race reproduction or Windows smoke test.

Fixes #1095.

@EhabY
EhabY force-pushed the fix/1095-update-reconnect-race branch 2 times, most recently from 668ce42 to bf287af Compare September 17, 2026 17:11
@EhabY EhabY changed the title fix: coordinate workspace updates and prevent SSH autostart races fix: queue workspace updates as one build and stop autostart races Sep 17, 2026
@EhabY
EhabY force-pushed the fix/1095-update-reconnect-race branch from 5585be7 to 43ff3d8 Compare September 18, 2026 12:26
@EhabY EhabY changed the title fix: queue workspace updates as one build and stop autostart races fix: queue workspace updates as one build Sep 18, 2026
@EhabY
EhabY force-pushed the fix/1095-update-reconnect-race branch from 43ff3d8 to 131d30b Compare September 18, 2026 12:47
@EhabY
EhabY marked this pull request as ready for review September 18, 2026 12:47
@EhabY
EhabY force-pushed the fix/1095-update-reconnect-race branch 2 times, most recently from 44bc3f5 to dc31dd9 Compare September 18, 2026 22:24
`coder update` runs a stop build and then a start build. Between the
two, the extension's own `coder ssh` reconnect autostarts the workspace
on the old template version, so the update's start build is rejected
with "A workspace build is already active" and the workspace comes back
unchanged.

On servers from 2.36, post a single build that carries the start in
`on_success`, so nothing can take the build slot in between. Leave
`template_version_id` unset on the follow-up build, because pinning it
requires template update permission and the update targets the active
version anyway. Servers before 2.36 keep the `coder update` path, and
CLIs before 2.24 keep the REST path.

While that build is queued, the state machine follows it instead of
starting the workspace itself, and a failed update asks before
connecting to the existing version instead of falling back silently.

Split the version-keyed capabilities into `CliFeatureSet` and
`ServerFeatureSet` so the new check reads the deployment version rather
than the CLI's. The Tasks panel moves with it, bounded to the releases
that serve `/api/v2/tasks`: 2.29 through 2.34.

Fixes #1095
@EhabY
EhabY force-pushed the fix/1095-update-reconnect-race branch from dc31dd9 to df24ea4 Compare September 18, 2026 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Updating workspace via VS Code fails

1 participant