SSE Live Updates Caused Multi-Tab Logouts Due to Refresh Token Race
After a team added Server-Sent Events live updates to their app, users with two or more windows open were suddenly logged out without clicking anything. The cause was that every open tab's SSE stream ended at the same moment when the shared access token expired, so all tabs reconnected, received 401 errors, and called the refresh endpoint together. Keycloak's refresh token rotation treated the reused token as an attack and ended the entire session, clearing the shared cookies. The fix involves coordinating refreshes across tabs, for example with the browser's Web Locks API, so that only one tab refreshes at a time and the others reuse the new tokens.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in