[bug]: Remote (SSH) tab freezes after laptop sleep and does not recover on its own
Summary
When using emdash against a remote dev server over SSH, a tab becomes unresponsive after the laptop sleeps / the machine is away for a while. The tab stays frozen after the machine wakes and the network is back. The only way I've found to recover is to close the tab, open the conversations panel, and re-open the conversation — which appears to create a fresh session and works immediately. A refresh/reconnect action that revived the existing tab (or automatic recovery on wake) would avoid the manual dance.
Environment
- emdash: 1.1.38 (arm64)
- macOS: 26.5.2 (build 25F84), Apple Silicon
- Remote access: Tailscale SSH (Tailscale 1.98.8) to a remote Linux dev server
- Workflow: multiple projects/worktrees on the remote, several tabs open at once
Steps to reproduce
- Connect emdash to a remote server over SSH (in my case via Tailscale SSH).
- Open a tab (terminal + conversation) working in a remote worktree.
- Let the laptop go to sleep / walk away for a while.
- Return, wake the laptop; the network/Tailscale is back and normal SSH works again.
Expected: the tab reconnects and becomes usable again (automatically, or via an explicit reconnect/refresh).
Actual: the tab is frozen. It does not recover on its own. Closing the tab and re-opening the conversation from the conversations panel restores it.
Log observations
Logs from ~/Library/Application Support/emdash/logs/ over a ~13-day span (2026-07-01 → 2026-07-14). Counts of the relevant messages:
| Message | Count |
|---|---|
SshConnectionManager: connection error |
232 |
withRetry: retrying after error |
178 |
SshConversationProvider: replacement failed |
57 |
SshTerminalProvider: respawn failed |
58 |
SshTerminalProvider: respawn limit reached, giving up |
28 |
SshConnectionManager: max reconnect attempts reached |
1 |
Breakdown of the connection errors: read ECONNRESET ×197, Timed out while waiting for handshake ×21, read ETIMEDOUT ×12, connect ETIMEDOUT <ip>:22 ×2.
A representative cluster around one sleep/wake cycle (redacted):
06:04:12 error SshConnectionManager: connection error read ECONNRESET
06:04:12 warn LegacySshFilesRuntime: background error
06:04:12 warn LegacySshGitRepository: refs refresh failed SSH connection is not available
...
07:39:31 error SshConnectionManager: connection error read ETIMEDOUT
07:39:31 error SshConversationProvider: replacement failed Error: SSH connection is not available
And a cluster ending in the terminal giving up:
21:27:13 error SshConnectionManager: connection error read ECONNRESET
21:27:14 error SshTerminalProvider: respawn failed Error: SSH connection is not available
21:27:14 error SshConversationProvider: replacement failed Error: SSH connection is not available
21:44:50 error SshConnectionManager: connection error read ECONNRESET
21:44:50 error SshTerminalProvider: respawn limit reached, giving up
What stands out in the logs:
- The connection layer usually does recover (178 retries, only 1
max reconnect attempts reachedacross 232 errors). - The per-tab providers are the ones that end up permanently stopped:
SshTerminalProvider: respawn limit reached, giving up(28×) andSshConversationProvider: replacement failed(57×). After "giving up", I see no further recovery attempts for that tab in the logs. - There are no power/sleep/wake/resume-related log lines at all around these events.
- Downstream, the tab spams
SSH connection is not availablefor background work (git refs refresh, file-tree scan) while frozen.
This lines up with the observed behavior: a new tab connects fine (connection is healthy), but the existing frozen tab never comes back — consistent with the tab's provider having stopped retrying, rather than the connection being unavailable.
Technical detail
Inspecting the bundled out/main/index.js of the installed 1.1.38 build (values quoted as-is, no conclusions drawn):
SshConnectionManagerreconnects on a fixed scheduleRECONNECT_DELAYS_MS = [1000, 2000, 5000, 10000, 20000](5 attempts, ~38 s total). After the last one it logsmax reconnect attempts reached, emits areconnect-failedevent, and clears its reconnecting state for that connection.SshTerminalProviderandSshConversationProviderrespawn/replace their PTY session on unexpected exit, but capped atMAX_RESPAWNS = 2; after that they logrespawn limit reached, giving upand delete the session.- On a
reconnectedevent,SshTerminalProvider.rehydrate()re-spawns terminals that no longer have a live session. TherespawnCountsmap is only cleared when the provider gives up or is torn down — I did not find it being reset on a successful reconnect. - The respawn/reconnect paths react to socket-level events (
error/close); I found no reference to ElectronpowerMonitoror OS sleep/wake events, which matches the absence of any power/wake lines in the logs.
These are observations from the shipped bundle; I have not traced every path, and the exact interaction that leaves a tab permanently frozen may differ.
Related
- generalaction/emdash#2703 (closed/completed) — App crashes when the Mac wakes from sleep. Same trigger (stale SSH connection after sleep) and same
SSH connection is not availableerror family, but a different outcome (process crash, since fixed) versus the frozen-but-alive tab described here. - generalaction/emdash#2853 (open) — the
LegacySshFilesRuntimefile-tree-scan errors that spam the log while a tab is in this state overlap with the load-storm report there. - generalaction/emdash#1215 (open) — tmux-backed persistent PTY sessions, which would change this lifecycle.
Hypothesis (not verified beyond the log evidence)
It looks like the terminal/conversation provider has a small, bounded respawn/replacement budget that gets exhausted across repeated disconnect cycles during sleep, after which it stops retrying for that tab — with no trigger (e.g. OS wake/resume, network-online, or window-focus) that resets it or forces a fresh reconnect. That would explain why only a full teardown + recreate (close tab → re-open conversation) recovers it. I have not confirmed the exact thresholds or code paths; the above is inferred from the log patterns.
Possible directions (open to whatever fits the design)
- Recover the existing tab on wake/network-return instead of requiring close + re-open.
- A user-visible Reconnect / Refresh control on a stuck tab that re-runs the same path the "re-open conversation" flow uses, without losing the tab.
- Reset the retry/respawn budget (or resume retrying) when connectivity is regained.
Happy to provide fuller log excerpts if useful.
Hi @dgarros,
Thanks for the detailed report and analysis. The log breakdown and observations from the shipped bundle are especially helpful. We’ve added this to our current development cycle. As an initial recovery option, we’re considering Refresh action in the conversation tab’s context menu, allowing a stuck session to reconnect without closing and reopening the tab.
We’ll also investigate the underlying recovery behavior after sleep and network reconnection. We’ll share an update here as we make progress. Arne
closing as outdated