[Bug]: Desktop: relay environment discovery never runs/retries when the app starts without network, remote T3 Connect environment stays "offline" until the next restart#17106
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/web
Steps to reproduce
Summary
My laptop came out of Modern Standby on a phone hotspot (5G), and the desktop app lost its connection to my remote T3 Connect environment. I then restarted the app while the network was still coming up. After that restart, the app never ran relay environment discovery. The remote environment stayed "offline" for 46 minutes, even though the server was healthy and reachable the whole time. Clicking Reconnect did nothing on the network.
Restarting the app again once the network was stable fixed it immediately. This time it was on a regular Wi-Fi network. Relay discovery ran 3 seconds after startup, cleared the stored offline report, and connected.
This looks like a client-side counterpart of #12061, where something that fails once at startup is never retried.
Server side was healthy
Checked at the same time:
- The service had been up for 3 days with 0 restarts, and the local origin
/.well-known/t3/environmentreturned 200. - cloudflared was running, with only routine re-registrations in the log.
- From the laptop on the same hotspot,
relay.t3.codesreturned 200, and the environment endpoint via a separate path (Tailscale) also returned 200.
Suspected cause
Likely in packages/client-runtime (relay/discovery.ts, state/relayDiscovery.ts), surfaced via apps/web/src/state/relay.ts in the desktop renderer.
At startup, the relay environment discovery (managedRelaySession → RelayEnvironmentDiscovery.refreshStatus) either fails before it is traced, or is skipped while the network/relay isn't reachable yet. Either way it is never scheduled again. The stored offline report for the remote environment is only cleared by a successful refreshStatus, so the environment keeps showing offline. retryNow for that environment doesn't trigger discovery, so Reconnect has no effect.
The earlier drop during standby (07:42 – 08:28) may be a separate issue: occasional relay requests succeeded but the websocket was never re-established. The trace for that period doesn't show why.
Steps to reproduce (best guess)
- Connect the desktop app to a remote environment via T3 Connect.
- Disconnect the network (or sleep the laptop and wake it on a network that takes a while to come up).
- Start or restart the desktop app while there is no connectivity yet.
- Restore connectivity. The remote environment stays offline, and Reconnect does nothing.
- Restart the app with working network. The environment connects within seconds.
Related
- #12061: the same "fails once at startup, never retried" pattern for the host-side relay link (clock skew)
- #15051, #13266: the remote environment never connects because it is switched off. Ruled out here, the toggle was On
- #4589: subscriptions die after a transport blip until the client restarts
Expected behavior
- Relay discovery and the connection to the remote environment are retried with backoff, or when connectivity returns. A startup without network shouldn't leave the environment offline until the next restart.
- Reconnect actually re-runs discovery and starts a connection attempt.
Actual behavior
- After the 08:30 restart, the only spans in the trace for that whole period are:
EnvironmentSupervisor.make+ConnectionDriver.connectforPrimaryConnectionTarget;- the laptop's own managed tunnel recovery, which failed 6× and then succeeded at 08:32.
- No
clientRuntime.managedRelaySession.readClerkToken,RelayEnvironmentDiscovery.refreshStatusorweb.managedRelayDpopSigner.createProofbetween 08:30 and 09:16. - Every Reconnect click logs
EnvironmentRegistry.retryNow→EnvironmentSupervisor.retryNow→setState, and no request follows. - The app keeps throwing
"<env> is not connected."until 08:49.
Impact
Major degradation or frequent failure
Version or commit
Desktop app 0.0.45 (Windows); remote service t3@0.0.45
Environment
Windows 11 Home 10.0.26200, T3 Code desktop 0.0.45. Remote: Ubuntu Server, t3@0.0.45 as systemd user service via T3 Connect (managed cloudflared, TUNNEL_TRANSPORT_PROTOCOL=http2). Client network: phone hotspot (5G) during the failure, office Wi-Fi when it recovered. Remote environment toggle was On.
Logs or stack traces
| 1 | Source: %USERPROFILE%\.t3\userdata\logs\{server,desktop}.trace.ndjson — 2026-10-08, local time UTC+2, IDs redacted |
| 2 | |
| 3 | 07:25:41–07:56:04 Windows Modern Standby (Kernel-Power 506/507) |
| 4 | 07:42:36 exception "<env> is not connected." (repeats ~6/min, 292x total until 09:16) |
| 5 | 07:56:31 EnvironmentRegistry.run status=ERROR "Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing." |
| 6 | 07:58:10 web.managedRelayDpopSigner.createProof status=OK |
| 7 | 08:28:07 web.managedRelayDpopSigner.createProof status=OK |
| 8 | 08:28:38 EnvironmentRegistry.run status=ERROR "Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing." |
| 9 | 08:28:48 web.managedRelayDpopSigner.createProof status=OK <-- last relay request until 09:16 |
| 10 | |
| 11 | 08:30:06 desktop.startup <-- restart #1 (network not ready yet) |
| 12 | 08:30:13–08:31:34 environment.cloud.registerManagedCloudTunnelRecovery x6 FAILED "relay returned an unexpected response" |
| 13 | 08:30:16 EnvironmentSupervisor.make target=PrimaryConnectionTarget (no remote env) |
| 14 | 08:31:15 EnvironmentRegistry.retryNow -> EnvironmentSupervisor.retryNow -> setState (Reconnect click, no request) |
| 15 | 08:32:09 environment.cloud.registerManagedCloudTunnelRecovery OK -> activateManagedTunnel 08:32:17 |
| 16 | 08:38:52 EnvironmentRegistry.retryNow -> EnvironmentSupervisor.retryNow -> setState (no request) |
| 17 | 08:39:38 EnvironmentRegistry.retryNow -> EnvironmentSupervisor.retryNow -> setState (no request) |
| 18 | 08:30–09:16 0x managedRelaySession.readClerkToken, 0x RelayEnvironmentDiscovery.*, 0x createProof |
| 19 | |
| 20 | 09:16:08 desktop.startup <-- restart #2 (on Wi-Fi) |
| 21 | 09:16:16 EnvironmentSupervisor.make target=PrimaryConnectionTarget |
| 22 | 09:16:18 clientRuntime.managedRelaySession.readClerkToken OK |
| 23 | 09:16:19 RelayEnvironmentDiscovery.refreshStatus OK |
| 24 | 09:16:21 EnvironmentRegistry.setCompatibility -> RelayEnvironmentDiscovery.clearOfflineReport -> updateEnvironment |
| 25 | 09:16:19/28 web.managedRelayDpopSigner.createProof OK <-- remote environment online |
Screenshots, recordings, or supporting files
No response
Workaround
No response