Skip to content

[Bug]: Direct (Tailscale) routes keep resending an expired bearer login although the environment's T3 Connect token works on those addresses #44820

Done

Description

@devahschaefers

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/desktop (logic in packages/client-runtime)

Summary

An environment has a working T3 Connect route and Tailscale routes whose saved bearer login has expired. The client keeps sending the expired bearer token to the Tailscale addresses once a minute, indefinitely. It already holds a valid T3 Connect DPoP token, and the code says that token works on the environment's tailnet address (authorizeDpop with directEndpoint), but the Tailscale routes never use it. The only fix is to pair again, and #17014 says re-pairing doesn't reliably reach sibling or learned routes, which leaves removing the whole environment.

#17014 covers re-pairing not updating sibling routes, and #33183 covers the 30-day expiry with no renewal before 0.1.11. This issue is about the step neither covers: an environment that is still authenticated through Connect should not leave its direct routes stuck on a dead login.

Steps to reproduce

  1. Before 0.1.11, pair a desktop client to two Linux hosts so each environment gets a plain bearer login and Tailscale routes (MagicDNS HTTPS and http://<tailnet-ip>:3773). Also link T3 Connect.
  2. Upgrade the client and hosts to 0.1.14 nightly and wait past the bearer session's 30-day expiry.
  3. Open Settings → Environments.

Expected behavior

While the environment has a valid T3 Connect session, its Tailscale/LAN routes authorize with that DPoP token, which authorizeDpop({ directEndpoint }) already supports. Failing that, once the host returns 401 "Session token expired", the client stops resending that token and offers one action that repairs every direct route.

Actual behavior

  • T3 Connect is "In use". Both Tailscale routes show "Sign-in refused", and nothing on screen offers a way to fix them except Remove.
  • The client never stops retrying. Each attempt does GET /.well-known/t3/environment (200), then POST /api/auth/websocket-ticket/rpc (401). One host logged 802 Rejected authenticated session credential. reason="Session token expired." in a day.
  • Client span chain for each failure: ConnectionDriver.preflight → broker.prepare → broker.authorize {target.kind: BearerConnectionTarget} → broker.bearer → remote.authorizeBearer → issueRemoteWebSocketTicket → "The environment rejected this client's credentials (invalid_credential)."
  • t3 auth session list on each host shows only a live dpop-access-token / cloud-connect session for this client, plus an MCP bearer session. Nothing usable exists for the direct routes, so retrying cannot succeed.

Why (read against main @ a505181)

  • resolver.ts#L154: a bearer route uses the Connect token only if its profile says authorization: "t3-connect". Otherwise it loads the stored credential and calls authorizeBearer, which has no renewal or fallback.
  • routes.ts#L322 (mergeLearnedRoutes): learned routes that already exist are kept as they are. authorization: "t3-connect" is set only on newly learned origins. A route learned from (or saved as) a direct bearer pairing therefore keeps borrowing that dead credential, even after Connect becomes the active route.
  • service.ts#L86: "a token from the relay also works on the environment's LAN or tailnet address". The fallback exists; this path just never uses it.
  • EnvironmentAuth.ts#L1169: only DPoP pairing-link sessions renew. A bearer login from before 0.1.11 is bound to expire, so every environment paired before 0.1.11 will reach this state.

Suggested fix

  1. When a bearer route's credential is rejected as expired or revoked and the environment has a Connect route, switch that route to authorization: "t3-connect" (or try authorizeDpop({ directEndpoint }) before giving up). In mergeLearnedRoutes, upgrade existing learned routes to t3-connect once the shared credential is dead.
  2. Stop retrying a credential the host rejected as expired, and show one "Re-pair" action for the environment, as in [Bug]: After re-pairing, an environment's other routes keep the expired login, and removing a route deletes the new one #17014 fixes 2 and 3.

Impact

Major degradation or frequent failure

Version or commit

Client: T3 Code Nightly desktop 0.1.14-nightly.20261127.5359. Hosts: t3 0.1.14-nightly.20261127.5359. Code checked on main a505181.

Environment

macOS arm64 desktop client; two Linux x64 hosts. Reached over Tailscale (direct UDP; MagicDNS HTTPS through Tailscale Serve, and :3773). T3 Connect linked.

Related

#17014, #33183, #17591

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions