Auth: fix verify page stuck on spinner under StrictMode - #50
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Graphite Automations"Request reviewers once CI passes" took an action on this PR • (07/10/26)2 reviewers were added to this PR based on Henry Chen's automation. |
| queryClient.setQueryData(sessionQueryKey, session); | ||
| return session; | ||
| }, | ||
| enabled: token !== null, |
There was a problem hiding this comment.
if the token is missing, is there any error handling in this library? or does it just fail silently
There was a problem hiding this comment.
The query is gated with enabled: token !== null, so it never fires without a token — no silent network call. The page itself handles that case explicitly: if (!token || verify.isError) renders the "Sign-in link problem" alert with a link back to /login, and there's a test covering the missing-token path ("a missing token shows the error state without calling the API").
2576e29 to
874f7c4
Compare
cbf9d36 to
5681d50
Compare
874f7c4 to
f8279ce
Compare
5681d50 to
3f5cf30
Compare
The verify POST fired from a mount effect via useMutation, and StrictMode's simulated remount detaches the mutation observer from its in-flight request — the component never saw success (no navigation, spinner forever) even though the backend signed the user in. Model the token exchange as a query keyed by the token instead: the StrictMode double-mount dedupes to a single POST and the remounted observer re-attaches to the cached entry. The page now derives navigation from query state, dropping the effect + ref guard entirely. Wrap the test renderer in StrictMode to mirror main.tsx so this class of bug fails in vitest instead of only in the browser. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
3f5cf30 to
dc25815
Compare
f8279ce to
4ffd84d
Compare
|




The verify POST fired from a mount effect via useMutation, and
StrictMode's simulated remount detaches the mutation observer from its
in-flight request — the component never saw success (no navigation,
spinner forever) even though the backend signed the user in.
Model the token exchange as a query keyed by the token instead: the
StrictMode double-mount dedupes to a single POST and the remounted
observer re-attaches to the cached entry. The page now derives
navigation from query state, dropping the effect + ref guard entirely.
Wrap the test renderer in StrictMode to mirror main.tsx so this class
of bug fails in vitest instead of only in the browser.
Co-Authored-By: Claude Fable 5 noreply@anthropic.com