feat: implement concurrent-safe token refreshing with session-aware error handling

This commit is contained in:
estifanos
2026-08-19 09:00:05 +00:00
parent b860e57227
commit 1eeb4c5cc3
4 changed files with 76 additions and 9 deletions

View File

@@ -41,8 +41,13 @@ export const baseQueryWithReauth: BaseQueryFn<
try {
await _onTokenExpired();
result = await baseQuery(args, api, extraOptions);
} catch {
_onAuthFailure?.();
} catch (err) {
// Only a rejected refresh token ends the session. A network blip or a
// 5xx leaves the original 401 for the screen to report, rather than
// throwing the user out of a session that is still valid.
if ((err as { sessionExpired?: boolean })?.sessionExpired) {
_onAuthFailure?.();
}
}
} else {
_onAuthFailure?.();