Skip to content

bug(frontend): after a deploy, a stale tab loops POST /api/auth/logout → 401 (~20–50 req/s) and signs every fresh login out #2852

Open

Description

@obasilakis

Summary

After a frontend deploy, a browser tab still running the previous build got stuck in an unbounded POST /api/auth/logout → 401 loop (~20 req/s average, ~50 req/s at peak, 54,781 requests in 46 minutes). While that tab was open, admin sign-in in any other tab was impossible: /api/token returned 200 and /api/users/me returned 200, the console logged 🔐 Admin login: authenticated as admin, and the page stayed on /login. Reloading the stale tab stopped the loop immediately, and the next sign-in worked.

The loop needs two things together: the old tab's lazy /login route chunk returning 404 (the deploy replaced the hashed assets), and a 401 handler that re-enters logout() whenever the route has not left /.

Related: #2791 / PR #2811 (cross-tab session sync). That PR is what makes the runaway tab break other tabs, but the loop itself ran on the pre-#2811 build. See "Current dev" below.

Timeline (UTC, from trinity-frontend nginx access log, single Firefox/macOS user agent)

Time Event
11:26:32 Instance pulls dev 0bddbc95 → daf65406 (10 commits, includes #2811)
11:35:51 trinity-frontend recreated with the new build
13:47:18 Stale tab (loaded before the deploy): GET /assets/Login-XsWFBlt2.js → 404, then immediately POST /api/auth/logout → 401, repeating. Referer is / throughout. Bursts of GET /api/setup/status every ~5 s (router guard re-running)
~14:30 Loop rate ~50 req/s (6,006 logout 401s in 2 minutes). The rate grew over time, consistent with each new 401 from a poll starting another chain
14:27:48–14:27:58 Fresh tab (new build): three sign-in attempts. Each was POST /api/token 200 + GET /api/users/me 200, and no further requests. The page stayed on /login
14:33:01 Stale tab reloaded (GET / 200). Last logout 401 at 14:33:00, zero afterwards
14:33:11 Sign-in: POST /api/token 200, then the dashboard loads normally (/api/agents, /api/tags, … all 200)

The request that first triggered the 401 handling at 13:47:18 is not in the log (the first logged request from that tab is the chunk 404).

Mechanism (code read at 0bddbc95, the build the stale tab was running)

  1. src/frontend/src/main.js global response interceptor: on any 401, if router.currentRoute.value.path is not /login, /setup or /m, it calls authStore.logout() and then router.push('/login').
  2. stores/auth.js::logout() clears local state and then await axios.post('/api/auth/logout'). With the token expired, or already removed from the axios defaults by an earlier call, the revoke returns 401.
  3. That 401 goes back into the same interceptor. router.push('/login') never succeeded, because Login is a lazy route (component: () => import('../views/Login.vue')) and its chunk hash no longer exists after the deploy. So currentPath is still / and the interceptor calls logout() again, which fires another revoke, and so on.
  4. Normally step 3 terminates because navigation to /login succeeds and the path guard stops re-entry. The missing chunk removes that termination.

Why it breaks sign-in in other tabs: each logout() iteration runs localStorage.removeItem('token'). A fresh tab on the new build writes its token, and the looping tab removes it within milliseconds. The new build's storage listener (#2811, main.js → reactToStorageEvent) then sees no token and calls applySessionEndedElsewhere(), so the fresh tab is signed out right after /api/users/me.

Current dev (daf65406), code read only, not reproduced

Steps to reproduce (proposed, not yet run)

  1. Sign in on build A and leave the tab on / without visiting /login.
  2. Deploy build B (new asset hashes), without reloading the tab.
  3. Make the tab's session 401 (expire or revoke the token).
  4. Observe POST /api/auth/logout 401s repeating in the frontend access log. Sign in from a second tab: token 200, and the page stays on /login.

Expected

  • A 401 on the session revoke never re-enters the logout path.
  • A failed dynamic import after a deploy recovers (for example a one-time full reload on vite:preloadError) instead of leaving the router stuck.
  • One misbehaving tab cannot prevent sign-in in the rest of the browser.

Environment

  • Trinity dev daf65406 (0.9.5-rc2), enterprise edition, PostgreSQL; previous build 0bddbc95
  • Firefox 155, macOS

Workaround

Reload or close every open Trinity tab that was loaded before the deploy, then sign in.

Activity

  1. added
    priority-p2
    type-bug
    theme-reliability
    complexity-low
    on Sep 16, 2026
  2. added
    status-ready
    on Sep 17, 2026
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

    complexity-lowpriority-p2status-readytheme-reliabilitytype-bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions