fix(ui): Stop the sign-in start card flashing after a code is accepted - #9331
Draft
dmoerner wants to merge 1 commit into
Draft
fix(ui): Stop the sign-in start card flashing after a code is accepted#9331dmoerner wants to merge 1 commit into
dmoerner wants to merge 1 commit into
Conversation
After a verification code was accepted, the sign-in start card could reappear for a moment before the app rendered its signed-in state. `SignInFactorOne` has a guard that sends you back to the start of the flow when the sign-in has no status left, written for "user tried a social button, then came back". #6462 gave that guard an early-return while `setActive` is running, and in doing so made it re-run every time `setActive` starts or stops rather than only on mount. So it runs once more as `setActive` finishes -- and at that point a successful sign-in also has no status left, because completing it consumed the sign-in. The guard can't tell the two cases apart, so it sends a user who just signed in back to the start card. It only showed up sometimes because it needs the card to re-render both during `setActive` and again after it, racing whatever the app does once the session exists. The fix records that `setActive` took over, so a card that has handed off navigation never sends the user back. Behaviour for a genuinely abandoned sign-in is unchanged. `SignInFactorTwo` has the same guard and the same bug, so it gets the same fix. This PR was written by Claude based on a reproduction video that I was able to record. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 715a736 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/electron
@clerk/electron-passkeys
@clerk/eslint-plugin
@clerk/expo
@clerk/expo-google-signin
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
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.
After a verification code was accepted, the sign-in start card could reappear for a moment before the app rendered its signed-in state.
SignInFactorOnehas a guard that sends you back to the start of the flow when the sign-in has no status left, written for "user tried a social button, then came back". #6462 gave that guard an early-return whilesetActiveis running, and in doing so made it re-run every timesetActivestarts or stops rather than only on mount. So it runs once more assetActivefinishes -- and at that point a successful sign-in also has no status left, because completing it consumed the sign-in. The guard can't tell the two cases apart, so it sends a user who just signed in back to the start card.It only showed up sometimes because it needs the card to re-render both during
setActiveand again after it, racing whatever the app does once the session exists.The fix records that
setActivetook over, so a card that has handed off navigation never sends the user back. Behaviour for a genuinely abandoned sign-in is unchanged.SignInFactorTwohas the same guard and the same bug, so it gets the same fix.This PR was written by Claude based on a reproduction video that I was able to record. Reproduction video, at round 6.85 seconds:
sign-in-bounce.mp4
Description
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change