Skip to content

Stuck session when GitHub token renewal is temporarily unavailable: no way to sign out, refresh retried on every request #3879

Done

Description

@integry

Problem

When a signed-in user's GitHub token has expired and renewal fails with a temporary error, the API answers every request with 503 GITHUB_TOKEN_REFRESH_UNAVAILABLE (packages/api/auth.ts, ensureAuthenticated; also the socket path and routes/githubRoutes.ts). The UI has no handling for this code. The dashboard loads with errors, the layout never gets a user, and there is no logout button or any other way out. The user is stuck until the session is deleted on the server.

Seen live on a Fly instance (device sign-in from #3868, relay answering 404 before integry/propr-routing#341 was deployed). The instance log showed GitHub user grant refresh failed with HTTP 404 twice per request, dozens per minute, because every API call retries the refresh immediately.

Wanted

  1. The session is never cleared automatically on a temporary failure. A fluke (relay restart, GitHub blip, network) must not log anyone out. Keep the current classification: only reauth-required clears the session.
  2. The UI recognises GITHUB_TOKEN_REFRESH_UNAVAILABLE (HTTP 503 and the socket error) and shows a clear, non-blocking state instead of broken pages. For example, a banner or a full-page notice: "GitHub sign-in can't be renewed right now." It offers:
    • Retry, which re-checks /api/auth/user;
    • Sign out, which calls /api/auth/logout and then goes to the login page. The user can then sign in again, with a device code or OAuth.
      It may retry by itself in the background with backoff, and it clears when a request succeeds.
  3. Logout always works. /api/auth/logout (and the UI's logout control) must work whatever the token state, including when the user can't be loaded. Make sure the sign-out control can be reached in this state on desktop and mobile layouts (Layout.tsx, MobileProfileRow.tsx).
  4. Backoff on the server. After a temporary refresh failure for a session or grant, don't call the refresh endpoint again on every request. Remember a short retry-after, for example 30s growing to 5 min, and answer 503 from memory until then. Concurrent requests share one in-flight refresh. The github_user_grants.renewal_retry_after_ms column may already fit this.
  5. Tests:
    • an API test showing that a temporary failure keeps the session and that refresh calls are throttled;
    • a UI test showing that a 503 with this code renders the notice with working Retry and Sign out controls;
    • a test showing that logout succeeds with an expired, unrenewable token.

Out of scope

Classification of which failures need a new sign-in (#3868 handles device sign-ins). Relay-side changes.

Activity

  1. propr-dev commented on Nov 29, 2026

    @propr-dev
    Contributor

    🤖 AI processing has started for this issue using codex agent with gpt-6.2-sol model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Agent: codex
    • Model: gpt-6.2-sol
    • Branch: 3879/gpt-6.2-sol-stuck-session-when-github-20261129-0014-j5q
    • Base Branch: 3758-epic-runtime-abstraction-sc0
    • Worktree: issue-3879-20261129-0014-gpt-6.2-sol-j5q

    🔍 Track Task Execution

  2. integry commented on Dec 1, 2026

    @integry
    OwnerAuthor

    Done in #3880, which merged into the runtime epic; the epic merged into main with #3774 and ships in 0.9.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions