Repository navigation
Description
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)
src/frontend/src/main.jsglobal response interceptor: on any 401, ifrouter.currentRoute.value.pathis not/login,/setupor/m, it callsauthStore.logout()and thenrouter.push('/login').stores/auth.js::logout()clears local state and thenawait axios.post('/api/auth/logout'). With the token expired, or already removed from the axios defaults by an earlier call, the revoke returns 401.- That 401 goes back into the same interceptor.
router.push('/login')never succeeded, becauseLoginis a lazy route (component: () => import('../views/Login.vue')) and its chunk hash no longer exists after the deploy. SocurrentPathis still/and the interceptor callslogout()again, which fires another revoke, and so on. - Normally step 3 terminates because navigation to
/loginsucceeds 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
- The revoke storm itself should not recur from a tab running a post-fix(session): one platform credential, one 401 verdict, one handler (#2791) #2811 build:
logout()only sends the revokeif (revoking), andthis.tokenis null after the first pass. - The enabler is still present: there is no chunk-load failure recovery anywhere in
src/frontend/src(novite:preloadErrorlistener, norouter.onError). After any deploy, a stale tab cannot navigate to a lazy route it has not loaded yet, including/login. That leaves the tab on a dead page that keeps reacting to 401s. - Every instance updated across fix(session): one platform credential, one 401 verdict, one handler (#2791) #2811 will carry pre-fix(session): one platform credential, one 401 verdict, one handler (#2791) #2811 tabs for a while, and those tabs still have the old loop. That exposure is one-off per tab, but it will happen on every instance that updates past fix(session): one platform credential, one 401 verdict, one handler (#2791) #2811.
Steps to reproduce (proposed, not yet run)
- Sign in on build A and leave the tab on
/without visiting/login. - Deploy build B (new asset hashes), without reloading the tab.
- Make the tab's session 401 (expire or revoke the token).
- Observe
POST /api/auth/logout401s 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 build0bddbc95 - Firefox 155, macOS
Workaround
Reload or close every open Trinity tab that was loaded before the deploy, then sign in.
Activity