Repository navigation
fix(auth): stop reload from redirecting logged-in users to /login - #474
Merged
Merged
Conversation
1 task
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.
Summary
/mypage) while logged in redirected to/login, even though the token was still valid inlocalStorage<StrictMode>double-invokesAuthProvider's effect in dev. The first invocation'sgetCurrentUsercall gets aborted by React's Strict Mode cleanup, butAuthProviderdidn't check forAbortErrorbefore callingsetUser(null)/setLoading(false)— unlike every other hook in this codebase (useCreateUser, etc.), which all guard against acting on an aborted request's result. The aborted call's rejection resolved before the second (real) request finished, soRequireAuthbriefly sawisLoading:false, user:nulland navigated away before the real request could completeAuthProvider'sgetCurrentUser.catch/.finallywith the sameisAbortErrorcheck used elsewhereTest plan
npx tsc --noEmitnpx jest— added a regression test that reproduces the StrictMode double-effect race; confirmed it fails against the pre-fix code and passes with the fixnpm run format:check