Repository navigation
Conversation
2c3b2cc to
dd04c11
Compare
7856c8c to
3be8358
Compare
3be8358 to
29b28ad
Compare
|
I tried this against a real agent over tailnet (DERP only, then closed the DERP server so neither side sees a close), and I don't think the keep-alive count is what ends a dead client's connection. Our tailscale fork sets TCP max retries to 5 (
A few things follow from that, as far as I can tell:
Have you seen a VS Code row stay Ongoing on a build with #32353 and only the fork bump? If not, could we land the bump on its own first and see whether the opt-in is still needed? |
29b28ad to
78e48f3
Compare
78e48f3 to
656dc39
Compare
656dc39 to
9ec39b8
Compare
9ec39b8 to
40845bf
Compare
877b8ce to
25bc35d
Compare
Clients that reconnect on their own can send CODER_SSH_CLIENT_ALIVE_INTERVAL and CODER_SSH_CLIENT_ALIVE_COUNT_MAX so the agent probes their connection more often than CODER_AGENT_SSH_MAX_TIMEOUT allows, applied with the fork's SessionKeepAlive.SetClientAlive.
25bc35d to
a428f10
Compare
|
Closed: dogfood testing with #32601 (coder/ssh#8) shows dead IDE connections already close shortly after the client goes away, so the client-driven keep-alive isn't needed for now (CLIENT-1110 canceled). It can be reopened if fully idle sessions turn out to stay Ongoing. Written with Coder Agents and reviewed by @EhabY. |
Follow-up to #32601, which bumped the fork to coder/ssh#8 and landed on its own, per #32444 (comment).
Over tailnet, a client that vanishes (crash, power loss, network loss) is only dropped once the agent writes to it: the netstack's TCP retry limit ends the connection about 10 to 30 seconds later. An idle session gets no writes until the agent's keep-alive, every third of
CODER_AGENT_SSH_MAX_TIMEOUT(24h by default), so its connection log row stays "Ongoing" until then. The client's ownServerAliveIntervalkeep-alive does not help, because a vanished client sends nothing for the agent to answer.Clients that reconnect on their own, such as VS Code and Cursor, can now send both
CODER_SSH_CLIENT_ALIVE_INTERVAL(seconds, raised to 5 if lower) andCODER_SSH_CLIENT_ALIVE_COUNT_MAXin a session's environment. The agent applies them to that connection with the fork'sSessionKeepAlive.SetClientAlive, so it probes on the client's schedule. Both variables are stripped from the session environment, and are ignored unless the interval is shorter than the agent's own. Clients that send nothing keep today's behavior. The Coder VS Code extension sends itsServerAliveIntervalandServerAliveCountMax(coder/vscode-coder#1203).Refs CLIENT-1110.
Verification
TestSSHServer_KeepAliveClosesSilentConnection/ClientKeepAlive(client asks for 5s x 1, then stops answering) closes the connection; it never closes without theSetClientAlivecall.TestExtractClientAlivecovers parsing, the 5s floor and the shorter-than-agent rule.A throwaway test with a real agent and client over DERP only, where DERP stops relaying without closing (not committed). Idle session, cut after 2s of quiet:
main[email protected]every 10sDecision log
ServerAlive*values only make the client probe the agent; the agent never sees them, so the client has to send them.SetClientAlive) instead of a second loop in the agent, so a connection has one loop and one timer.Written with Coder Agents and reviewed by @EhabY.