[Bug]: False-positive "Remote connection dropped" on SSH worktrees while the SSH transport is actually alive
Summary
Orca intermittently reports "Remote connection dropped. Click Reconnect on the SSH target before retrying." for SSH-backed remote worktrees, while the underlying SSH connection is actually still alive and healthy. Reconnecting works immediately, but the interruption is frequent and disruptive. Evidence below shows the transport never went down — this looks like a client-side false-positive disconnect in Orca's remote-session layer rather than a real network/host failure.
- Orca version: 1.4.128 (desktop, macOS)
- Setup: Multiple independent remote worktrees, each backed by a different remote macOS host over SSH (imported from
~/.ssh/config).
What I see (user-facing)
- Clicking back into an idle remote worktree surfaces:
Remote connection dropped. Click Reconnect on the SSH target before retrying. - In the trace logs, each event shows up as:
renderer_unhandled_rejection→Error invoking remote method 'fs:pathExists': Error: Remote connection dropped. Click Reconnect on the SSH target before retrying.sidebar_worktree_activatebreadcrumb withsshDisconnected: true
The key finding: the SSH transport was NOT down
I instrumented one drop end-to-end. At the moment Orca reported the disconnect, I checked the backing host directly:
- ~47 seconds after Orca declared the drop, a fresh
ssh <host> 'uptime'from the same machine returned in ~0.44s, with unbroken uptime (no reboot, no reconnect). - The host's sshd logged zero disconnect/teardown events across the entire surrounding window (checked via unified log for the sshd process).
- The host was not asleep (
pmsetshowed sleep fully disabled; no sleep/wake events in the window). - Network path to the host was not degraded (sub-second latency, no packet loss around the event).
So from the host's perspective the SSH session was never torn down. Orca reported "Remote connection dropped" while the connection was demonstrably healthy.
Not host-specific
This reproduces across several independent remote hosts (different machines, different SSH endpoints) — always the same error string and the same sshDisconnected: true breadcrumb. That, plus the healthy-transport evidence above, points at Orca's client-side session handling rather than any single host, network, or sleep condition.
Likely mechanism / hypotheses
- Orca appears to hold remote sessions in a bundled
ssh2(Node) client.ssh2's keepalive (keepaliveInterval) defaults to off, so an idle multiplexed channel / SFTP-style channel can silently stall or be considered dead even though the TCP + SSH transport is fine. - The failure surfaces specifically through the
fs:pathExistsremote method on worktree (re)activation, which suggests the per-worktree channel/IPC is what's being declared dead — possibly a channel-level timeout being reported as a whole-connection drop. - Server-side keepalive on the host (
ClientAliveInterval) did not prevent it, consistent with the drop originating on the client/channel side rather than the transport.
What would help
- Enable client keepalives on Orca's
ssh2connections (e.g.keepaliveInterval/keepaliveCountMax) so idle remote worktrees stay warm. - Distinguish a dead transport from a dead channel/IPC before declaring "Remote connection dropped" — and prefer transparent auto-reconnect of the channel over surfacing a manual "Reconnect" prompt when the transport is still alive.
- Expose a configurable keepalive / reconnect setting. There is currently no client-side keepalive or reconnect knob exposed (confirmed by inspecting the app's config/preferences), so users can't mitigate this themselves.
Environment
- Orca 1.4.128, macOS (Apple Silicon)
- Remote worktrees over SSH, hosts imported from
~/.ssh/config
Happy to provide additional (sanitized) trace snippets or run further instrumentation on a live drop if that helps narrow it down.
Second live repro, tightly correlated in time — reinforces that this is a false-positive at the client layer, not a real transport failure:
- T+0 — Orca emitted
renderer_unhandled_rejection→Error invoking remote method 'fs:pathExists': Error: Remote connection dropped. Click Reconnect on the SSH target before retrying. - T+24s — a fresh
ssh <host> 'uptime'from the same machine returned in ~0.42s, uptime unbroken (host up 51 days, no reboot/reconnect). - Same window: the host's sshd logged no disconnect/teardown, and there were no sleep/wake events (sleep is disabled on the host).
- Confirmed the trace log was current at capture time (newest trace line was ~5s old), so this isn't a log-flush artifact — the drop and the healthy-transport check are genuinely ~24s apart.
Notably, this occurrence surfaced only as the fs:pathExists "Remote connection dropped" rejection, with no accompanying sshDisconnected: true activation breadcrumb — consistent with the failure being a per-worktree channel/IPC declaring itself dead rather than the SSH transport actually going down.
I now have two independent, time-correlated captures showing the same thing (drop reported while ssh latency stays sub-second and the host's sshd never logs a teardown). Glad to instrument further or share more sanitized trace detail on request.
Root-caused from the relay-log evidence above plus a code walk — this is a client-side false positive in the mux dead-link detector after any pause the app can't receive through (system sleep, App Nap timer throttling, lid close), with a second, by-design-but-noisy behavior stacked on top.
Mechanism:
- The app-level channel multiplexer sends a keepalive every 5s and tracks each one as an unacked message (
src/main/ssh/ssh-channel-multiplexer.ts—sendKeepAlivestampsunackedTimestamps). So at any instant there is almost always a <5s-old unacked entry. - The dead-link check runs on a timer and compares wall-clock time with no wake/pause guard:
noDataReceived = now - lastReceivedAt > 20sANDoldestUnacked > 20s. During sleep/App Nap neither data nor timer ticks arrive; on the first tick after wake, both conditions are trivially true (the pre-pause keepalive is now "stale") →Connection timed out (no ack received)→dispose('connection_lost')→ relay-lost auto-reconnect. That is exactly theSocket client closed → Grace started → Handshake OK → accepted=Nflap in the relay log — the relay and the SSH transport were healthy the whole time, which the log proves (ptys=1 throughout, instant re-handshake). - Independently, a real system sleep→resume force-reconnects every target unconditionally (
registerPowerMonitorReconnectinsrc/main/ipc/ssh.ts) — so every doze/wake cycle produces a reconnect + overlay flash even when the link would have survived.
This also explains the reported clustering "around idle / worktree reactivation": reactivation is when the wake happens and the stale check fires. And it explains periodic ~10-minute cycles on machines with aggressive power settings.
Fix plan (small, scoped):
- Wake-guard in the mux timeout check: track the last tick time; when
now - lastTickis far beyond the interval (we were paused), resetlastReceivedAt, re-stamp/flush unacked tracking, send a fresh keepalive, and let the next full window make an honest liveness determination instead of killing the channel on stale pre-pause state. - Probe-before-teardown on power resume: send a keepalive and only
reconnect()if it goes unanswered briefly, instead of unconditionally tearing down live connections. - Add timestamps to the relay log lines (the one gap in this diagnosis — we couldn't correlate flaps to typing without them).
Working on a PR for these.