Desktop: drop a box when its wire closes, so a dead connection can't hang the board - #127
Merged
Merged
Conversation
…hang the board A box whose transport died silently (Mac asleep, Tailscale flap, the relay's remote end gone) stayed registered as a live engine. Nothing ever removed it: the health probe that tears down a broken box is ws-only, and an RPC has no per-call timeout, so every call routed into that box waited forever — the box stayed green on the board while swallowing requests. Creating the first task for a repo on such a box left "Setting up <repo> on <box>…" on screen indefinitely: it was parked on connect()'s already-held path, which asks the box for system:hello, so the clone it was reporting had not even been asked for. On the box itself that clone takes ~3.5s. - A closed wire now drops its backend (connect wires transport.onClose -> disconnect), wire-agnostic: the ws probe only catches a HALF-open socket, while a real close is all SSH ever gives us. - Cache each box's handshake SystemInfo instead of re-asking on every status read. connected() was one system:hello PER BOX on every connect/disconnect/ install, so one stale box hung the whole list — and with it connect()'s already-held path. The local engine is still asked live (in-process, and its agent list changes under us); installAgent refreshes the cached info. - Merge reads (projects/agents/loops list) tolerate an engine that can't answer: per-backend cap, and its slice is dropped instead of the union. A bare Promise.all over a stale backend hung the entire board's project list, and rejected the whole list if one engine errored. - Hold SSH connections with ServerAliveInterval=15/ServerAliveCountMax=3. OpenSSH's own liveness check defaults to OFF, so a black-holed connection left the ssh child alive with nothing coming back; 15x3 gives a real exit in ~45s, which closes the pipe and drops the box. Verified live against the Hetzner box through the edited transport (handshake, a board read, onClose on teardown, and projects:clone in 3.5s), and in the dev app: killing one box's relay drops that box, leaves the sibling connection and the app untouched.
pallaoro
enabled auto-merge (squash)
August 17, 2026 10:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
A box whose transport died silently — Mac asleep, Tailscale flap, the relay's remote end gone — stayed registered as a live engine. Nothing ever removed it: the health probe that tears down a broken box is
ws-only, and an RPC has no per-call timeout, so every call routed into that box waited forever. The box stayed green on the board while swallowing requests.Creating the first task for a repo on such a box left "Setting up <repo> on <box>…" on screen indefinitely. It was parked on
connect()'s already-held path — which asks the box forsystem:hello— so the clone the toast was reporting had not even been requested yet. On the box that clone takes ~3.5s.Changes
connect()wirestransport.onClose → disconnect(alias), wire-agnostic on purpose: the ws probe only catches a half-open socket, while a real close is all SSH ever gives us.SystemInfoinstead of re-asking on every status read.connected()was onesystem:helloper box on every connect / disconnect / install, so one stale box hung the whole list — and with itconnect()'s already-held path. The local engine is still asked live (in-process, and its agent list changes under us);installAgentrefreshes the cached info.projects:list/agents:list/loops:listget a per-backend cap and drop that engine's slice instead of the union. A barePromise.allover a stale backend hung the entire board's project list, and rejected the whole list if one engine errored.ServerAliveInterval=15/ServerAliveCountMax=3. OpenSSH's own liveness check defaults to off, so a black-holed connection left thesshchild alive with nothing coming back. 15×3 gives a real exit in ~45s — which closes the pipe, and a closed pipe is what drops the box.Deliberately not a per-call RPC timeout:
projects:clone, the installer andtasks:cleanuplegitimately run for minutes. Liveness belongs to the channel, not the call.Verification
bun test— 154 pass, including two new regressions: a merge read survives an engine that never answers, and one that errors.projects:listsucceed,onClosefires on teardown, andprojects:clonecompletes in 3.5s.Docs:
online-ateam.mdnow states that a box dropping mid-session shows as disconnected, with the keepalive detection window.