Description
There is a race condition when multiple instances of the CLI try to autostart a stopped workspace at the same time (for example, via coder ssh
or coder port-forward
). This results in a 409 status code from the build attempt, which is treated as an error by the CLI:
start workspace with current template version:
github.com/coder/coder/v2/cli.getWorkspaceAndAgent
/go/pkg/mod/github.com/coder/coder/v2@v2.10.0/cli/ssh.go:602
- create workspace build:
github.com/coder/coder/v2/cli.startWorkspace
/go/pkg/mod/github.com/coder/coder/v2@v2.10.0/cli/start.go:145
- POST https://<...>/api/v2/workspaces/f2350bb0-7063-4e08-b2db-89e55a5418c7/builds: unexpected status code 409: A workspace build is already active.
Error: A workspace build is already active.
The CLI should handle 409 status codes by waiting for the build to complete.
This issue may also apply to other clients such as IDE plugins, in which case they would need similar fixes.