Skip to content

fix(ui): prevent infinite spinner on factor-two without active 2FA session#7774

Open
nikosdouvlis wants to merge 1 commit intomainfrom
nikos/fix-factor-two-infinite-spinner
Open

fix(ui): prevent infinite spinner on factor-two without active 2FA session#7774
nikosdouvlis wants to merge 1 commit intomainfrom
nikos/fix-factor-two-infinite-spinner

Conversation

@nikosdouvlis
Copy link
Member

@nikosdouvlis nikosdouvlis commented Feb 5, 2026

Summary

Users navigating directly to /sign-in#/factor-two without an active sign-in requiring 2FA would see an infinite loading spinner. This adds a status check to redirect them back to sign-in start, matching the existing pattern in SignInFactorOne.

  • Added useEffect to SignInFactorTwo that redirects when signIn.status is null, needs_identifier, or needs_first_factor
  • Dependency array only includes __internal_setActiveInProgress (not signIn.status) to avoid flash during valid sign-in completion

Why not signIn.status !== 'needs_second_factor'?

That condition catches complete status, causing a flash to the sign-in page before the final redirect. By explicitly checking for invalid statuses only, we avoid interfering with the normal sign-in completion flow.

Test plan

  • Direct navigation to /sign-in#/factor-two without active sign-in → redirects to sign-in start
  • Valid MFA sign-in flow → completes without flash to sign-in page

🤖 Generated with Claude Code

Summary by CodeRabbit

Bug Fixes

  • Fixed an infinite loading spinner that appeared when navigating directly to the two-factor authentication sign-in page without an active 2FA session. The authentication flow now properly redirects users to the appropriate sign-in step when necessary, ensuring a smoother sign-in experience.

@vercel
Copy link

vercel bot commented Feb 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Feb 5, 2026 4:12pm

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Feb 5, 2026

🦋 Changeset detected

Latest commit: 6b510af

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@clerk/ui Patch
@clerk/chrome-extension Patch

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

This change adds a patch-level fix to the sign-in factor-two route handling. A changelog entry documents the fix for an infinite loading spinner. The SignInFactorTwo component now imports runtime hooks from Clerk and a router utility. A new useEffect hook has been added that redirects users back to the sign-in start path when the component mounts if the sign-in status is null, 'needs\_identifier', or 'needs\_first\_factor', unless an operation is already in progress. The redirect is skipped when sign-in status is 'complete' to allow setActive to handle navigation. The component's rendering logic remains unchanged.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main fix in the changeset: preventing an infinite spinner when accessing the factor-two route without an active 2FA session.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

…ssion

Why:
Users navigating directly to /sign-in#/factor-two without an active
sign-in requiring 2FA would see an infinite loading spinner because
there was no status check to redirect them back to sign-in start.

What changed:
Added useEffect to SignInFactorTwo that redirects to sign-in start
when signIn.status is null, needs_identifier, or needs_first_factor.
Matches the existing pattern in SignInFactorOne.

Key detail: dependency array only includes __internal_setActiveInProgress
(not signIn.status) to avoid triggering redirect during valid sign-in
completion when status changes to null.
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 5, 2026

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7774

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@7774

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@7774

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@7774

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@7774

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7774

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@7774

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@7774

@clerk/express

npm i https://pkg.pr.new/@clerk/express@7774

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@7774

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@7774

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@7774

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@7774

@clerk/react

npm i https://pkg.pr.new/@clerk/react@7774

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@7774

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@7774

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@7774

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@7774

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@7774

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@7774

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@7774

commit: 6b510af

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant