@@ -17,22 +17,35 @@ client that can never connect retries all day. Offline states and authentication
1717failures wait for a wakeup instead of spending attempts on unchanged conditions.
1818
1919Foregrounding, a network change, an explicit retry, and an offline report probe
20- the established session, and only a failed probe reconnects. Offline reports are
21- often wrong, for example for a loopback server. The OS can kill a suspended
22- socket without a close event, so a probe still unanswered after 500 ms asks the
23- host for its public descriptor over a fresh request, again each second until it
24- answers. If the host answers while the socket delivers no frame, the socket is
25- dead and is replaced, even while the network reports offline: at once on
26- loopback and LAN, and 2.5 seconds after the check starts elsewhere, where one
27- lost packet can stall a live socket. Without that evidence the probe deadline
28- decides: 3 seconds on loopback and LAN routes and after a long mobile
29- suspension, when the data on screen is stale; 15 seconds elsewhere, because a
30- tailnet over DERP or a VPN can be slower than that on a live socket. A long
31- suspension's probe that times out also replaces the socket regardless of the
32- network report. The web and desktop foreground probe skips the fresh request,
33- because a busy host can answer it before a queued probe. Foregrounding also
34- wakes a pending retry immediately. A long suspension restarts an in-flight
35- attempt; a short one leaves it alone.
20+ the established session instead of tearing it down. Offline reports are often
21+ wrong, for example for a loopback server. The OS can kill a suspended socket
22+ without a close event, so a probe still unanswered after 500 ms asks the host
23+ for its public descriptor over a fresh request, again each second until it
24+ answers. If the host answers while the socket delivers no frame, a replacement
25+ session starts connecting. The socket itself is declared dead, even while the
26+ network reports offline, immediately on loopback and LAN, and 2.5 seconds after
27+ the check starts elsewhere, where one lost packet can stall a live socket.
28+ Without that evidence the probe deadline decides: 3 seconds on loopback and LAN
29+ routes and after a long mobile suspension, when the data on screen is stale; 15
30+ seconds elsewhere, because a tailnet over DERP or a VPN can be slower than that
31+ on a live socket. A long suspension's probe that times out also replaces the
32+ socket regardless of the network report. The web and desktop foreground probe
33+ skips the fresh request, because a busy host can answer it before a queued
34+ probe. Foregrounding also wakes a pending retry immediately. A long suspension
35+ restarts an in-flight attempt; a short one leaves it alone. A long suspension
36+ also restarts a pending replacement, which may have stalled with the app.
37+
38+ A replacement that connects first takes over the session directly, so
39+ subscriptions move without the client showing a reconnect, unless it landed on a
40+ worse route than the live socket; then it waits as the fallback. One still
41+ connecting when the socket is declared dead becomes the reconnect attempt; one
42+ that is not an upgrade closes when the live socket proves alive. A network
43+ change restarts or starts a replacement at once, except on loopback, because it
44+ can strand the socket's route, for example when leaving a LAN, and anything
45+ opened over the old path; that costs one extra connection per environment per
46+ change. A better route connects beside the live session the same way and takes
47+ over when it connects on that route; if it fails, the live session stays and the
48+ route waits five minutes.
3649
3750The [ registry] ( ../../packages/client-runtime/src/connection/registry.ts ) scopes
3851connections by environment. An involuntary disconnect retains the registration
0 commit comments