Title: coder ssh: add retry loop for transient connection failures · Issue #24005 · coder/coder · GitHub
Open Graph Title: coder ssh: add retry loop for transient connection failures · Issue #24005 · coder/coder
X Title: coder ssh: add retry loop for transient connection failures · Issue #24005 · coder/coder
Description: coder ssh --stdio exits immediately on transient errors (DNS failure, connection timeout, API unreachable). When used as an SSH ProxyCommand, this causes VS Code's Remote SSH extension to throw a permanent SshResolverError.Create() error...
Open Graph Description: coder ssh --stdio exits immediately on transient errors (DNS failure, connection timeout, API unreachable). When used as an SSH ProxyCommand, this causes VS Code's Remote SSH extension to throw a p...
X Description: coder ssh --stdio exits immediately on transient errors (DNS failure, connection timeout, API unreachable). When used as an SSH ProxyCommand, this causes VS Code's Remote SSH extension to throw...
Opengraph URL: https://github.com/coder/coder/issues/24005
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"coder ssh: add retry loop for transient connection failures","articleBody":"`coder ssh --stdio` exits immediately on transient errors (DNS failure, connection timeout, API unreachable). When used as an SSH ProxyCommand, this causes VS Code's Remote SSH extension to throw a permanent `SshResolverError.Create()` error, which kills the reconnection loop on the first attempt. The user sees \"Reload Window\" even though the error would resolve itself in seconds.\n\n## Confirmed failure mode\n\nCaptured from `remote.SSH.logLevel: \"trace\"` during a real sleep/wake cycle on Linux with `systemd-resolved`:\n\n1. Wake from sleep, VS Code detects disconnect (\\~20s), starts reconnection\n2. Remote SSH extension spawns new SSH with ProxyCommand: `coder ssh --stdio`\n3. `coder ssh` immediately queries the workspace API\n4. **DNS lookup fails**: `dial tcp: lookup dev.coder.com: server misbehaving` (`systemd-resolved` not ready after wake)\n5. `coder ssh` exits immediately with error\n6. Remote SSH sees unparsable bash script output\n7. `SshResolverError.Create()` (permanent) -> \"Reload Window\"\n\nDNS recovers within seconds, but `coder ssh` has already exited. VS Code does not retry because the error is classified as permanent.\n\nThis affects any configuration where `coder ssh` errors produce terminal output that the Remote SSH extension tries to parse as bash script output (i.e. when `useLocalServer` is `false`). With `useLocalServer: true`, the local server manages SSH with its own retry logic and doesn't depend on script parsing, making it more resilient to transient ProxyCommand failures.\n\nA separate but related issue exists with the Coder Connect code path, where a broken tunnel causes a \\~55 minute hang before `coder ssh` exits. The retry loop proposed here would eventually recover from that too, but a dial timeout and tailnet fallback are needed to avoid the long wait. See [ENG-2346](https://linear.app/codercom/issue/ENG-2346/coder-ssh-coder-connect-path-has-no-dial-timeout-no-health-check-no).\n\n## Proposed change\n\nWrap the connection establishment logic in [`cli/ssh.go`](\u003chttps://github.com/coder/coder/blob/main/cli/ssh.go>) (handler function, lines \\~280-474) in a retry loop with backoff. This covers workspace resolution, API calls, agent readiness checks, and the dial to the workspace.\n\n```go\nretryDelays := []time.Duration{0, 2 * time.Second, 5 * time.Second, 10 * time.Second, 10 * time.Second}\n\nfor attempt := range retryDelays {\n err := connectAndServe(ctx, ...)\n if err == nil {\n return nil\n }\n if !isRetryable(err) || attempt == len(retryDelays)-1 {\n return err\n }\n logger.Warn(ctx, \"connection failed, retrying\",\n slog.Error(err), slog.F(\"attempt\", attempt+1))\n select {\n case \u003c-ctx.Done():\n return ctx.Err()\n case \u003c-time.After(retryDelays[attempt]):\n }\n}\n```\n\n**Error classification:**\n\n\u003c!-- linear:table-colwidths:266,266,266 -->\n| Error | Retryable? | Rationale |\n| -- | -- | -- |\n| DNS lookup failure | Yes | Resolvers recover within seconds after wake |\n| Connection refused / reset | Yes | Network interface may still be coming up |\n| Connection timeout | Yes | Transient network issue |\n| `DialAgent` failure | Yes | Tailnet coordinator may be temporarily unreachable |\n| HTTP 401/403 (auth) | No | Credentials are wrong, retrying won't help |\n| HTTP 404 (workspace not found) | No | Workspace doesn't exist |\n| Context canceled (SIGINT/SIGHUP) | No | User or SSH parent requested exit |\n\n## Current workaround\n\nA vscode-coder extension PR ([https://github.com/coder/vscode-coder/pull/872](\u003chttps://github.com/coder/vscode-coder/pull/872>)) wraps the ProxyCommand with a shell-level retry as a stopgap. This works but is fragile (platform-specific shell behavior, can't classify errors) and only helps VS Code/Cursor users.\n\n## Why the CLI is the right layer\n\n* Covers all editors (VS Code, Cursor, JetBrains, plain SSH)\n* Can accurately distinguish transient vs permanent errors\n* Avoids platform-specific shell wrapper issues\n* Logs retries to the `coder ssh` log file for debugging\n* Removes the need for an extension-side ProxyCommand retry wrapper","author":{"url":"https://github.com/EhabY","@type":"Person","name":"EhabY"},"datePublished":"2026-04-03T09:35:49Z","url":"https://github.com/coder/coder/issues/24005"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:782451ba-6e54-b6d2-275b-e29e5980b43c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D94:1201C:2C79F3A:3B1DB75:6B01C4C6 |
| html-safe-nonce | bdc59b9aa7290d9b14f400f7f35e5ca41757dccbb3efaa32f6c0f704fe924a96 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDk0OjEyMDFDOjJDNzlGM0E6M0IxREI3NTo2QjAxQzRDNiIsInZpc2l0b3JfaWQiOiIyMDk2MDA0ODI4OTE1NDE4MzEwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e89095ce36b0b8574bc8d2ec75402005bc106122a079c0072b8490cdbdef9f1a |
| hovercard-subject-tag | issue:4199550825 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/coder/coder/24005/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d6a8e22a0d6ca7fc7356a0fba5377a27226b8301738566f1968e2b23adc52aae/coder/coder/issues/24005 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d6a8e22a0d6ca7fc7356a0fba5377a27226b8301738566f1968e2b23adc52aae/coder/coder/issues/24005 |
| og:image:alt | coder ssh --stdio exits immediately on transient errors (DNS failure, connection timeout, API unreachable). When used as an SSH ProxyCommand, this causes VS Code's Remote SSH extension to throw a p... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | EhabY |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/coder/coder git https://github.com/coder/coder.git |
| octolytics-dimension-user_id | 95932066 |
| octolytics-dimension-user_login | coder |
| octolytics-dimension-repository_id | 440752086 |
| octolytics-dimension-repository_nwo | coder/coder |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 440752086 |
| octolytics-dimension-repository_network_root_nwo | coder/coder |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width