Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug] Desktop app crashes on launch after macOS 27 upgrade (DesktopLocalEnvironmentAuthSessionBootstrapError) #12918

Closedjamesvillarrubia(GitHub profile, opens in a new tab) opened this issue 4 comments

Area

apps/desktop

Steps to reproduce

  1. On macOS 27 (Build 26A428), build and launch the T3 Code desktop app (pnpm build:desktop && pnpm start:desktop).
  2. The app attempts to bootstrap the primary local environment on launch.
  3. The main-process /oauth/token exchange over loopback hits a transient failure (connection reset / brief 503 while the backend settles — newly common after the macOS 27 upgrade).
  4. The renderer crashes to the root error view during beforeLoad.

Expected behavior

The app boots to the chat view (or the pairing UI if unauthenticated), riding out the transient loopback failure.

Actual behavior

The app crashes to RootRouteErrorView with PrimaryEnvironmentRequestError caused by DesktopLocalEnvironmentAuthSessionBootstrapError: Failed to create the local desktop bearer session. No recovery path; relaunch may work if the transient condition has cleared.

Impact

Blocks work completely

Version or commit

main (pre-fix)

Environment

macOS 27.0 (Build 26A428), desktop app, Node v23.10.0

Logs or stack traces

PrimaryEnvironmentRequestError
  ← DesktopLocalEnvironmentAuthSessionBootstrapError: Failed to create the local desktop bearer session
  ← RemoteEnvironmentAuthUndeclaredStatusError (503) | RemoteEnvironmentAuthFetchError | TypeError

Workaround

Relaunch after the transient condition clears. No in-app recovery.

  1. Triage

    Confirmed on current main. This is a real launch-blocking desktop bug. Not a duplicate of #3513 (related brick path, different trigger). A fix PR is already open.

    What happens

    Desktop launch bootstraps the primary local environment by exchanging the desktop bootstrap token for a bearer session, then probing /api/auth/session from the renderer during root beforeLoad.

    On desktop that session call first asks the main process for a bearer token. The main process POSTs loopback /oauth/token once. A brief 503, connection reset, or TypeError (reported as more common after the macOS 27 upgrade) becomes DesktopLocalEnvironmentAuthSessionBootstrapError with no retry.

    That failure is returned over IPC. The renderer wraps it as PrimaryEnvironmentRequestError (fetch-session-state). The inner 503 is not visible after IPC, so the wrapper is labeled HTTP 500 and retryTransientBootstrap does not retry it. bootstrapServerAuth() awaits that first fetchSessionState() outside its try/catch, so the throw escapes beforeLoad and RootRouteErrorView is shown.

    Relaunch can succeed once the backend has settled. After #11291, Try again re-runs beforeLoad and may recover if the transient has cleared; it does not prevent the first-launch crash.

    Source

    Crash chain:

    1. apps/web/src/routes/__root.tsx beforeLoad → resolveInitialServerAuthGateState()
    2. apps/web/src/environments/primary/auth.ts bootstrapServerAuth() → unguarded fetchSessionState()
    3. apps/web/src/environments/primary/httpLayer.ts / desktopAuth.ts → getLocalEnvironmentBearerToken()
    4. apps/desktop/src/ipc/methods/window.ts → DesktopLocalEnvironmentAuth.getBearerToken
    5. apps/desktop/src/backend/DesktopLocalEnvironmentAuth.ts → single bootstrapRemoteBearerSession (no retry)
    6. packages/client-runtime/src/authorization/remote.ts + packages/client-runtime/src/rpc/http.ts → /oauth/token 503/reset/TypeError

    The cookie-exchange path in the renderer already retries 502/503/504 and degrades exchange failures to requires-auth. The desktop bearer path does not.

    This is a desktop reliability gap, not a macOS-only code path. macOS 27 is the reported trigger (loopback timing while the backend settles).

    • Fix already open: #12919 (Fixes #12918) — main-process transient retry on bearer bootstrap; renderer degrades a failed initial session fetch to requires-auth instead of crashing.
    • Related, keep open: #3513 — broader “startup session probe bricks the app” issue (session-store writes, generic probe failure, diagnosability). #12918 is the specific no-retry bearer /oauth/token slice.
    • Partial overlay recovery already on main: #11291 (Try again → router.invalidate()).

    Suggested next step

    Review/merge #12919. No second PR needed. After merge, this issue should close via the existing Fixes #12918 line. Leave #3513 open for the remaining degrade/diagnosability work.

  2. juliusmarminge added labelsaccepted

  3. juliusmarminge added labelsbug

  4. juliusmarminge added labelsvia-triage

  5. Also hitting this on macOS 26.6.2 (25G83) with T3 Code 0.0.42, so it's not limited to macOS 27. Same chain on launch: PrimaryEnvironmentRequestError caused by Error invoking remote method 'desktop:get-local-environment-bearer-token': DesktopLocalEnvironmentAuthSessionBootstrapError: Failed to create the local desktop bearer session.

  6. Error still in 0.0.45 - deleting everything and reinstall doesn't help, the app says "MacBook Pro is not connected." when trying to open a local folder as new project for a local environment.

  7. Still hitting this on T3 Code (Nightly) 0.0.46-nightly.20261005.2702, macOS 27.0.1 (26A434), on a normal app restart. Same chain: PrimaryEnvironmentRequestError ← desktop:get-local-environment-bearer-token ← DesktopLocalEnvironmentAuthSessionBootstrapError. Relaunching recovered it. Looking forward to #12919 landing.

  8. juliusmarminge closed this

Sign in to join this conversation.