`signIn.sso()` (Future API) silently does nothing for OAuth when a SignIn already exists
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 58/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- next.js, react, typescript
- Domaine
- authentication, frontend
Piste de recherche
Start in packages/clerk-js/src/core/resources/SignIn.ts and read SignInFuture.sso, focusing on how shouldCreateSignIn handles an existing sign-in for OAuth strategies. Reproduce with the component and steps in the issue, then verify that sso() starts OAuth or returns a meaningful error when a sign-in already has an id. The issue does not name a test file.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Preliminary Checks
- I have reviewed the documentation: https://clerk.com/docs
- I have searched for existing issues: https://github.com/clerk/javascript/issues
- I have not already reached out to Clerk support via email or Discord (if you have, no need to open an issue here)
- This issue is not a question, general help request, or anything other than a bug report directly related to Clerk.
Reproduction
No public repository. Minimal component below (Next.js App Router, Future API). Happy to put together a repo if that helps.
Publishable key
Development instance, available on request.
Description
Related to #9006, but the trigger is different: no reset() is involved, and the button stays inert across page reloads.
With the Future API (useSignIn() from @clerk/nextjs, not /legacy), signIn.sso({ strategy: 'oauth_google', ... }) resolves with { error: null } without sending any request and without navigating, as soon as the client already holds a SignIn that has an id and no pending external redirect. A failed attempt with an unknown identifier is enough to get there. Since that sign-in lives on the client, it survives page reloads: "Continue with Google" stays dead for that browser until the sign-in goes away.
Steps to reproduce:
'use client';
import { useSignIn } from '@clerk/nextjs';
export default function Page() {
const { signIn } = useSignIn();
return (
<>
<button onClick={() => signIn?.create({ identifier: '[email protected]' })}>
1. Attempt with an unknown identifier
</button>
<button
onClick={async () => {
const { error } = await signIn!.sso({
strategy: 'oauth_google',
redirectUrl: '/',
redirectCallbackUrl: `${window.location.origin}/sso-callback`,
});
console.log('sso resolved', { error, id: signIn!.id, status: signIn!.status });
}}
>
2. Continue with Google
</button>
</>
);
}
- Click 1. The attempt fails with
form_identifier_not_found, and the client now holds aSignIn(sia_…) with statusneeds_identifier. In our app we first ran into it after a failedsignIn.password(). - Click 2.
- Optionally reload the page and click 2 again: same result.
Expected behavior:
sso() starts a new OAuth attempt and navigates to the provider, or at least resolves with an error saying why it can't.
Actual behavior:
sso() resolves with { error: null }. No request is sent to the Frontend API, nothing navigates, and signIn.id is unchanged.
Root cause (clerk-js 6.41.0, unchanged on main / 6.42.3), in SignInFuture.sso (packages/clerk-js/src/core/resources/SignIn.ts):
const hasPendingRedirect = !!this.#resource.firstFactorVerification.externalVerificationRedirectURL;
const wouldReplayStaleRedirect = strategy !== 'enterprise_sso' && hasPendingRedirect;
const shouldCreateSignIn = !this.#resource.id || wouldReplayStaleRedirect;
When the sign-in already has an id and no external redirect URL, shouldCreateSignIn is false. For oauth_* strategies nothing else runs afterwards (prepare_first_factor is only called for enterprise_sso), so pendingHandOff() returns null and the method returns without doing anything. The classic authenticateWithRedirect doesn't have this problem, since it creates a new sign-in unless continueSignIn is set.
Workaround without internals: when signIn.id is set, call signIn.reset(), then call sso() from an effect on the fresh signIn the hook returns on the next render. In 6.41.0 the reset does reach the hook on the next render; it just can't be used inside the same handler, which is #9006.
Possible fixes:
- create a new sign-in for
oauth_*strategies when reusing the existing one would not produce a redirect, or - resolve with an
errorinstead of a silent no-op.
Environment
@clerk/nextjs: 7.3.2
@clerk/react: 6.6.1
@clerk/shared: 4.10.1
@clerk/clerk-js: 6.41.0 (loaded from the Frontend API)
next: 15.5.18
react: 18.2.0
OS: macOS; browser: Chromium-based
- Langage dominant
- TypeScript
- Étoiles
- 1.8k
- Forks
- 492
- Merge moyen
- 1 j 8 h
- PR mergées (30 j)
- 374
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de clerk/javascript
-
<SignIn />: the reset password code step renders an empty, focusable back button with no accessible namePeut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
clerk/javascript#10708 ·
Les mainteneurs répondent en général sous 1 jour
-
Built-in reverification dialog lacks an accessible name (aria-dialog-name)Peut-être pris @ItsShivam05 l’a pris il y a 5 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
clerk/javascript#10548 ·
Les mainteneurs répondent en général sous 1 jour
-
MFA enrollment QR SVG lacks an accessible name (svg-img-alt)Peut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
clerk/javascript#10547 ·
Les mainteneurs répondent en général sous 1 jour
-
<SignIn />: first "Use email" click switches back to phone when `initialValues.phoneNumber` is setPeut-être pris @twicestruck l’a pris il y a 22 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
clerk/javascript#10487 ·
Les mainteneurs répondent en général sous 1 jour
-
useLoadedIsomorphicClerk misses "ready" when a ClerkProvider remounts after clerk-js has loaded — <ClerkLoading> never resolvesPeut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
clerk/javascript#10462 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de clerk/javascript
Issues similaires
-
`@angular/[email protected]` depends on vulnerable Vite 7.3.7 - GHSA-p4f5-76q4-ffq7 (Critical RCE)Ouvertearea: @angular/build
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
angular/angular-cli#34764 ·
Les mainteneurs répondent en général sous 1 jour
-
status/need-triage
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
google-gemini/gemini-cli#30384 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
P2
Difficulté 1/5 Moins d'une heure Accessibilité débutants 84/100
Les mainteneurs répondent en général sous 1 jour
-
bug ready-for-human
Difficulté 2/5 1-3 heures Accessibilité débutants 60/100
LucasSantana-Dev/Lucky#3150 ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement good first issue priority: low size: XS
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
Les mainteneurs répondent en général sous 1 jour