-
Notifications
You must be signed in to change notification settings - Fork 419
fix(clerk-js): Remove cache revalidation hooks from pending session handling #6389
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
fix(clerk-js): Remove cache revalidation hooks from pending session handling #6389
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
🦋 Changeset detectedLatest commit: 1035bce 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 |
7c17599 to
7286a45
Compare
📝 WalkthroughWalkthroughThe changes remove cache revalidation hooks from the handling of pending sessions in the '@clerk/clerk-js' package. Specifically, the invocation of the Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
⏰ 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). (5)
🪧 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 (
|
NicolasLopes7
left a comment
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.
The changes looks straightforward enough 👍
iagodahlem
left a comment
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.
Couldn't test it yet, having troubles to setup playgrounds, will try it again later and give this one a try too!
Examples could be trying to extract the userId with auth({ treatPendingAsSignedOut: false })
Maybe we should mention that in the docs as well.
@iagodahlem We already have My idea is that it'd be mostly used for API routes or server actions. The majority of the B2B app logics will require to treat pending as signed-out to make sure orgs are defined so I can imagine that |
7286a45 to
1035bce
Compare
@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: |
Oh, I think I get it, makes sense to me, thanks for explaining it @LauraBeatris! 🙌 |
Description
This PR removes
onBeforeSetActiveandonAfterSetActivefrom being executed on the pending session handling withinsetActiveThis was leading to multiple issues of
SignInandSignUpgetting unmounted, since the server would refetch/refresh components and leave thesessionwith anundefinedstate, causingwithCoreSessionGuardto unmount AIOs.We didn't have these issues outside of after-auth flows (meaning when
pendingstatus doesn't exist and it goes from an empty session toactive) sincesetActivewould always execute Next.js router navigation to a page outside of AIOs.Tradeoffs
Since those cache revalidation hooks aren't executed, it's possible that RSCs and middleware logic that relies on the pending session, doesn't get trigger once the AIO is on the
select-organizationscreen. Examples could be trying to extract theuserIdwithauth({ treatPendingAsSignedOut: false })We think the tradeoff is worth tho, since atm, there's no clear indication that this would make sense while using AIOs in an after-auth flow.
If the developer wants to rely on the pending session granularly as a signed-in state on server-side logic, they can do so with custom pages by ejecting out of AIOs with
<ClerkProvider taskUrls={{ 'select-organization': '/my-server-rendered-page' />Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit