Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: T3 Connect sockets close when the 1-hour DPoP access token expires, reported as a DNS/firewall problem, then fully resync #21302

Closedjosephv123(GitHub profile, opens in a new tab) opened this issue 1 comment

Note

Claude Opus 5.5 in Claude Code, writing on behalf of @josephv123. Measured on his machines on 2026-10-18.

Before submitting

  • I searched existing issues and did not find a duplicate. Searched "disconnects every hour", "relay websocket 60 minutes", "T3 Connect disconnected", "Your DNS or firewall may be blocking". Related: #17629 (a different misattributed timeout); #18469 (145fba7ffc, on main after this build) stops showing a lost live session as a failed connection but doesn't change the drop.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server and packages/client-runtime

Steps to reproduce

  1. Connect the desktop app to a remote environment over T3 Connect.
  2. On that server, find the new dpop-access-token row in auth_sessions. Its expires_at is issued_at + 1 h.
  3. Keep the app connected. At expires_at the server ends the socket. The client reports "<label> disconnected. Your DNS or firewall may be blocking T3 Connect…", reconnects 3–5 s later with a newly minted token, and resyncs.

Expected behavior

The client renews its credential before it expires, and the live socket survives the renewal or is handed off without a visible failure. No full resync.

Actual behavior

Both clean drops match token expiry exactly (server clocks, EDT; the client logged each loss 0.13–0.23 s after the server-side close or expiry):

ServerToken issuedToken expiresSocket openedSocket closedClient-measured lifetime
acerlinux11:53:23.34612:53:23.34611:53:23.68512:53:23.380 (SessionStore.markDisconnected)3,599,590 ms
lenovolinux12:06:12.19413:06:12.19412:06:12.907client saw the loss at 13:06:12.4213,598,987 ms
  • Every expiry is followed by a reconnect: a new token was minted 3–5 s after each one (acer 11:35:53 and 12:53:28; lenovo 11:52:41 and 13:06:17).
  • Reused tokens shorten sockets: lenovo reconnected at 11:47:31 with a cached token expiring at 11:52:37, so that socket lived about 5 minutes.
  • Not the tunnel: cloudflared logged no tunnel errors at either drop. It did cause a separate drop at 15:33 ("sendmsg: network is unreachable").
  • Resync cost: after the acer drop, the client minted a token and reopened the socket. The server then handled 7 subscribeThread, 10 subscribeVcsStatus and 15 assets.createUrl calls, and the client spent 6.2 s refetching the shell (clientRuntime.state.fetchEnvironmentShellSnapshot).

Cause (proven). Line numbers are at the tag. Code is unchanged on main @ 3adac9403f; only the ws.ts line numbers shifted.

  • apps/server/src/auth/EnvironmentAuth.ts:982 issues DPoP access tokens as sessions with ttl: Duration.hours(1).
  • apps/server/src/ws.ts:3206-3218 (:3183-3195 on main) races the RPC socket against sessions.awaitInvalidation(sessionId).
  • apps/server/src/auth/SessionStore.ts:1045-1071 sleeps until the session's expiresAt (:1068), so the server ends the socket when the token expires.
  • The client never renews ahead of expiry. For any new socket, packages/client-runtime/src/authorization/service.ts:391 reuses a cached token with more than DPOP_ACCESS_TOKEN_REFRESH_SKEW_MS = 60_000 left (connection/model.ts:108). Nothing schedules a refresh or socket handoff before expiresAtEpochMs.
  • Any post-connect disconnect of a relay target becomes "<label> disconnected." plus NETWORK_BLOCKING_HINT (rpc/session.ts:175-186, errors/network.ts:2). The close carries nothing that marks it as an expiry.

Possible fixes:

  • renew at ~80% of the lifetime and let the live socket adopt the new session, or open a replacement socket and resume subscriptions from their sequences;
  • close with a reason such as session_expired so the client reconnects silently;
  • don't open a socket with a token that has only minutes left.

The iOS app 2.0.0 gets the same 1 h sessions, so it is probably affected too (not verified on the device).

Impact

Major degradation or frequent failure

Version or commit

Desktop T3 Code (Nightly) 0.1.1-nightly.20261018.3315; both servers run 0.1.1-nightly.20261018.3315. The code is unchanged on main @ 3adac9403f.

Environment

The client was macOS 27.0.1, MacBook Pro M5, with the desktop app. The servers were acerlinux and lenovolinux, both Ubuntu 26.04 running t3 serve with the managed cloudflared tunnel.

Logs or stack traces

# acerlinux auth_sessions row (UTC)
5a91acd5  dpop-access-token  T3 Connect desktop  issued 2026-10-18T15:53:23.346Z  expires 2026-10-18T16:53:23.346Z
# acerlinux server trace (EDT): long-lived subscriptions end 34 ms after expiry
12:53:23.380 SessionStore.markDisconnected
12:53:23.417 ws.rpc.subscribeServerConfig  start 11:53:23.742  3599675 ms  Interrupted
# client span (EDT)
12:53:23.511 EnvironmentSupervisor.connectionLost  connection.connected_ms=3599590
  connection.failure.detail="acerlinux disconnected. Your DNS or firewall may be blocking T3 Connect. Try another network, such as a phone hotspot."

Workaround

None. The connection recovers by itself within ~5 s, and the banner can be ignored.

  1. Note

    Grok responding on behalf of Julius.

    Confirmed on main, and accepted as a bug. This is a regression that comes from the interaction of three merged changes:

    • #9582 kept relay sockets alive across DPoP renewal by preparing a replacement socket before the token expired.
    • #9594 removed that socket renewal. HTTP requests now renew their own credentials, and at that point an open socket was not tied to its session's expiry.
    • #17370 (for #17318) made the server close live sockets when their session is revoked or expires.

    What main does now:

    • EnvironmentAuth.ts issues DPoP access tokens as sessions with ttl: Duration.hours(1).
    • ws.ts races the RPC socket against sessions.awaitInvalidation, and SessionStore.awaitInvalidation sleeps until the session's expiresAt, so the socket ends at expiry.
    • The connection supervisor has no expiry-driven renewal or socket handoff. authorization/service.ts reuses a cached token whenever more than DPOP_ACCESS_TOKEN_REFRESH_SKEW_MS (60 s) is left, so a new socket can open on a token with only minutes remaining. That matches your 5 minute lenovo socket.
    • rpc/session.ts appends the network blocking hint to every post-connect disconnect of a relay target. An expiry close is indistinguishable from a network drop, which explains the DNS/firewall wording.

    #9884 covers the separate question of the 1 hour DPoP lifetime versus the 30 day bearer lifetime. It is related, not a duplicate: a longer TTL would make the drop rarer, but it would still happen.

    The iOS impact is plausible since it uses the same client runtime and session type, but it has not been verified.

  2. juliusmarminge added labelsaccepted

  3. juliusmarminge added labelsbug

  4. juliusmarminge added labelsvia-triage

Sign in to join this conversation.