-
Notifications
You must be signed in to change notification settings - Fork 419
fix(clerk-js): Fix SSO callback for after-auth custom flows #6430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 613f916 The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 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 Git ↗︎
|
ccbd1c9 to
81f7d47
Compare
handleRedirectCallback for after-auth400b738 to
e958769
Compare
📝 WalkthroughWalkthroughThis change set updates the single sign-on (SSO) callback handling logic in the Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15–20 minutes Complexity label: Moderate 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (7)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
dec2bc3 to
40f1d91
Compare
40f1d91 to
3d93747
Compare
3d93747 to
fd897cf
Compare
fd897cf to
a6914a3
Compare
a6914a3 to
0cd32ec
Compare
0cd32ec to
f78707a
Compare
packages/clerk-js/src/core/clerk.ts
Outdated
| // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
| this.#instanceType!, | ||
|
|
||
| this.#instanceType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to check why my linter is making those changes on editor save... it ends up leading to a lot of build errors.
0719d8a to
cc20781
Compare
packages/clerk-js/src/core/clerk.ts
Outdated
| return this.setActive({ | ||
| await this.setActive({ | ||
| session: su.sessionId, | ||
| redirectUrl: redirectUrls.getAfterSignUpUrl(), | ||
| }); | ||
| return this.__internal_navigateToTaskIfAvailable({ redirectUrlComplete: redirectUrls.getAfterSignUpUrl() }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear, this doesn't impact custom flows, and developers shouldn't have to do it.
On their custom pages, Clerk.handleRedirectCallback will always navigate to the pending task route.
8c9e577 to
a899642
Compare
bb88da7 to
5af7c9d
Compare
`handleRedirectCallback` calls `setActive` with `redirectUrl` - this gets used to navigate to once the session transitions to `active` status. For custom flows, we don't recommend using `redirectUrl`, neither mention in our docs. This commit avoids passing `redirectUrlComplete` to `navigateToTask` to prevent race conditions on the navigation if the session is `active`.
5af7c9d to
613f916
Compare
Description
Context
After-auth flows always send the
redirect_urlasredirect_url_completein order to executehandleRedirectCallbackso that the SDK can control on navigating back to the pending tasks.We weren't dealing with the following cases:`
SSOCallbackand didn't cover custom flows that executehandleRedirectCallbackdirectlyactive, thenhandleRedirectCallbackshould redirect to theredirect_url_completefrom the initial flowsetActive, it wasn't navigating to tasks.Proposed fixes
handleRedirectCallbackredirect_url_completeas?redirect_urlparamFlows
Refer to the navigations below (I haven't implemented a custom spinner component for
handleRedirectCallbackWith
activesession and__internal_hasAfterAfterFlows:CleanShot.2025-07-29.at.19.01.40.mp4
With
pendingsession + transfer flow:CleanShot.2025-07-29.at.19.24.34.mp4
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
Bug Fixes
Tests
Documentation