Keep stored tokens on transient errors during profile fetch - #47
Open
paskal wants to merge 1 commit into
Open
Conversation
Previously, getProfileFetch removed both jwt and refreshToken from localStorage on any failure, including network errors and 5xx while the backend was unreachable at app start, permanently logging the user out. After this change tokens are cleared only when the server definitively rejects the session: a 401 on the profile followed by a refused refresh token, or a 401 on the retry with a freshly refreshed token. Transient refresh failures (network error, 5xx, 408 and 429 from /refresh) keep the tokens so the next launch can retry with the same session, and the expired-token error is no longer forwarded to errorFromServer on that path, since it would trigger a logOut that wipes those same tokens.
|
@paskal is attempting to deploy a commit to the ksinon-5464's projects Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
The one failing check here is the Vercel commit status ("Authorization required to deploy"). That is Vercel's fork-PR gate: deploying a commit from an external fork needs a member of the Vercel team to authorise it, so it cannot be cleared from this branch — no code or config change on the PR affects it. The Netlify deploy-preview, which actually builds the app, passes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously,
getProfileFetchremoved bothjwtandrefreshTokenfromlocalStorageon any failure, including network errors and 5xx while the backend was briefly unreachable at startup, permanently logging the user out.After this change tokens are cleared only when the server explicitly rejects the credentials:
Transient refresh failures (network error, 5xx, 408, 429 from
/refresh) keep the tokens so the next launch can retry with the same session. A non-401 profile error (e.g. 403/404) also keeps the tokens, since it does not indicate the stored credentials are invalid. The expired-token 401 is deliberately not forwarded toerrorFromServeron the transient path, since it would trigger alogOutthat wipes the very tokens being preserved.Adds tests, including one that executes nested thunks to prove no
LOGOUTis dispatched on a transient refresh failure.Note: the socket
TOKEN_EXPIREDpath instore.tshas the same transient-wipe behaviour and is left for a separate change.