Title: coder ssh: Coder Connect path has no dial timeout, no health check, no tailnet fallback · Issue #24006 · coder/coder · GitHub
Open Graph Title: coder ssh: Coder Connect path has no dial timeout, no health check, no tailnet fallback · Issue #24006 · coder/coder
X Title: coder ssh: Coder Connect path has no dial timeout, no health check, no tailnet fallback · Issue #24006 · coder/coder
Description: coder ssh --stdio via the Coder Connect path has no dial timeout, no connection health monitoring, and no fallback to tailnet when the tunnel is broken. This causes VS Code SSH reconnection to hang for ~55 minutes and then fail permanent...
Open Graph Description: coder ssh --stdio via the Coder Connect path has no dial timeout, no connection health monitoring, and no fallback to tailnet when the tunnel is broken. This causes VS Code SSH reconnection to hang...
X Description: coder ssh --stdio via the Coder Connect path has no dial timeout, no connection health monitoring, and no fallback to tailnet when the tunnel is broken. This causes VS Code SSH reconnection to hang...
Opengraph URL: https://github.com/coder/coder/issues/24006
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"coder ssh: Coder Connect path has no dial timeout, no health check, no tailnet fallback","articleBody":"`coder ssh --stdio` via the Coder Connect path has no dial timeout, no connection health monitoring, and no fallback to tailnet when the tunnel is broken. This causes VS Code SSH reconnection to hang for \\~55 minutes and then fail permanently after laptop sleep.\n\n## Environment\n\n* macOS (Apple Silicon), VS Code 1.113.0, Remote SSH 0.123.2026033115 (pre-release)\n* Coder Connect active (workspace reachable via `fd60:` IPv6 prefix)\n\n## What happened\n\nThe connection dropped several times over a few hours. Each time, VS Code reconnected in 3-8 seconds. Two of the drops showed \"Connection closed by remote host\" (workspace side actively closed); the others were silent. This instability needs workspace-side logs to diagnose.\n\nOn the fatal attempt, the Coder Connect tunnel was broken but DNS still resolved:\n\n```\nt+0s SSH spawns coder ssh --stdio as ProxyCommand\nt+2s coder ssh resolves workspace, ExistsViaCoderConnect() does DNS lookup for fd60:... → resolves → true\n Commits to Coder Connect path, calls runCoderConnectStdio()\n net.Dialer{}.DialContext(\"tcp\", \"fd60:...:22\") — no timeout set\n ... TCP dial hangs for 55 MINUTES (macOS default TCP timeout) ...\nt+55m macOS TCP stack: \"connect: operation timed out\", coder ssh exits\n SSH process dies, VS Code attempts reconnection but the session is already lost\n → \"Reload Window\"\n```\n\nThe laptop was put to sleep during the hang. When it woke the next morning, the stale TCP timeout error was already waiting.\n\n## Root cause\n\n### 1\\. [`ExistsViaCoderConnect`](\u003chttps://github.com/coder/coder/blob/main/codersdk/workspacesdk/workspacesdk.go>) is DNS-only\n\n```go\nfunc ExistsViaCoderConnect(ctx context.Context, hostname string) (bool, error) {\n ips, err := resolver.LookupIP(ctx, \"ip6\", hostname)\n // Only checks: does the hostname resolve to a fd60: prefix address?\n // Does NOT verify the address is actually reachable.\n}\n```\n\nA broken tunnel with working DNS causes `coder ssh` to commit to the Coder Connect path with no way to fall back.\n\n### 2\\. [`runCoderConnectStdio`](\u003chttps://github.com/coder/coder/blob/main/cli/ssh.go>) has no dial timeout\n\n```go\nfunc runCoderConnectStdio(ctx context.Context, addr string, ...) error {\n dialer := testOrDefaultDialer(ctx) // &net.Dialer{} — zero timeout\n conn, err := dialer.DialContext(ctx, \"tcp\", addr)\n if err != nil {\n return xerrors.Errorf(\"dial coder connect host: %w\", err) // fatal, no retry\n }\n agentssh.Bicopy(ctx, conn, &StdioRwc{...}) // bare io.Copy, no health check\n return nil\n}\n```\n\nNo `Timeout` on the dialer, so the only limit is the OS TCP stack (\\~55 min on macOS). On failure, `coder ssh` exits with no retry and no fallback to tailnet.\n\n### 3\\. No health monitoring on Coder Connect path\n\n\u003c!-- linear:table-colwidths:400,400,200 -->\n| | Coder Connect path | Tailnet path |\n| -- | -- | -- |\n| Dial timeout | None (OS default, \\~55 min macOS) | Context-based |\n| Health check | None | `setStatsCallback()`: pings every 3s, exits after 1 min of failures |\n| Workspace monitoring | None | `watchAndClose()`: watches workspace lifecycle via SSE |\n| Reconnection | None | Tailnet controller retries with backoff (50ms-10s) |\n| Fallback | None | DERP relay fallback if P2P fails |\n\n### 4\\. No tailnet fallback\n\nThe Coder Connect path is a hard `return` ([`cli/ssh.go:387`](\u003chttps://github.com/coder/coder/blob/main/cli/ssh.go>)):\n\n```go\nif exists {\n return runCoderConnectStdio(...) // if this fails, coder ssh exits\n}\n// tailnet path below is unreachable\n```\n\n## Suggested fixes\n\n1. **Add a dial timeout.** Wrap the Coder Connect attempt in a 30s context timeout so it fails fast instead of hanging for 55 minutes.\n2. **Fall back to tailnet on Coder Connect failure.** If `runCoderConnectStdio` errors, fall through to the `DialAgent` tailnet path instead of exiting.\n3. **Add health monitoring.** TCP keepalive or a periodic check similar to the tailnet path's `setStatsCallback`. Without this, a mid-session tunnel death is only detected when `io.Copy` returns (very slow on half-open TCP).\n4. **Consider a reachability check in** `ExistsViaCoderConnect`. A quick TCP connect (5s timeout) before committing would catch the broken-tunnel-with-valid-DNS case upfront.\n\nFixes 1-2 would also be partially covered by a general retry loop in `coder ssh` (see [ENG-2345](https://linear.app/codercom/issue/ENG-2345/coder-ssh-add-retry-loop-for-transient-connection-failures)).","author":{"url":"https://github.com/EhabY","@type":"Person","name":"EhabY"},"datePublished":"2026-04-03T09:39:25Z","url":"https://github.com/coder/coder/issues/24006"}
| 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:70ac045b-29d6-e430-e16b-b3f543029f63 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B6B4:23CF06:2D700BE:39E1E6A:6B01AA04 |
| html-safe-nonce | 4b2a704f0b109bd66a9cec4891749fb18ac0ec8212feb51dc30e5cd0c360e421 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNkI0OjIzQ0YwNjoyRDcwMEJFOjM5RTFFNkE6NkIwMUFBMDQiLCJ2aXNpdG9yX2lkIjoiODcwMDY5MjcxNjUwMzI4MDEzMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9de978d7eb61a740bcce2cbbd821ebaab6ac256526977cf15234cfd588c316e0 |
| hovercard-subject-tag | issue:4199568480 |
| 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/24006/issue_layout |
| twitter:image | https://opengraph.githubassets.com/adb9e3e78ec77dbf46d6f4c33179746050291508936750083877fe1736ea0550/coder/coder/issues/24006 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/adb9e3e78ec77dbf46d6f4c33179746050291508936750083877fe1736ea0550/coder/coder/issues/24006 |
| og:image:alt | coder ssh --stdio via the Coder Connect path has no dial timeout, no connection health monitoring, and no fallback to tailnet when the tunnel is broken. This causes VS Code SSH reconnection to hang... |
| 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