Fix MSAL infinite token-refresh loop

↗ view on GitHub · Cpodlaskilegal · 2026-05-06 · d4327cfd

onAuthStateChange listened for both LOGIN_SUCCESS and ACQUIRE_TOKEN_SUCCESS
and called getSession() inside the handler. getSession() invokes
acquireTokenSilent, which itself emits ACQUIRE_TOKEN_SUCCESS, re-entering
the handler indefinitely. Each iteration also fired ensureProfile() in
AuthContext, hammering the API and pegging Safari (the page would never
finish loading and other tabs in the same process would stall too).

Listening for ACQUIRE_TOKEN_SUCCESS is unnecessary anyway: silent
refreshes don't change the user/account. Now we only react to
LOGIN_SUCCESS and LOGOUT_SUCCESS.
Repository Cpodlaskilegal/mike
Author Cpodlaskilegal <christopher@podlaskilegal.com>
Authored
Parents 2d0a0e10
Stats 1 file changed , +5 , -4
Part of Azure Container Apps migration and Entra ID auth

Capture this commit into my fork

Download a Markdown prompt that tells Claude how to port this exact commit into your working tree. Run it via claude -p < capture-commit-d4327cfd.md from inside the repo you want the change in.

⬇ Download capture-commit-d4327cfd.md