-
Couldn't load subscription status.
- Fork 401
fix(clerk-js): Update server-side revalidation hooks for session status transition #6572
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
Changes from all commits
99f10bd
c03849f
d4cb0d0
3f2207f
16a87e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@clerk/clerk-js': patch | ||
| --- | ||
|
|
||
| Fix server-side cache revalidation for Next.js when transitioning from `active` to `pending` session |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ import { Header } from '@/ui/elements/Header'; | |
| import { OrganizationPreview } from '@/ui/elements/OrganizationPreview'; | ||
| import { useOrganizationListInView } from '@/ui/hooks/useOrganizationListInView'; | ||
| import { Add } from '@/ui/icons'; | ||
| import { useRouter } from '@/ui/router'; | ||
| import { handleError } from '@/ui/utils/errorHandler'; | ||
|
|
||
| type ChooseOrganizationScreenProps = { | ||
|
|
@@ -106,6 +107,7 @@ export const ChooseOrganizationScreen = (props: ChooseOrganizationScreenProps) = | |
| const MembershipPreview = (props: { organization: OrganizationResource }) => { | ||
| const { user } = useUser(); | ||
| const card = useCardState(); | ||
| const { navigate } = useRouter(); | ||
| const { redirectUrlComplete } = useTaskChooseOrganizationContext(); | ||
| const { isLoaded, setActive } = useOrganizationList(); | ||
| const { t } = useLocalizations(); | ||
|
|
@@ -119,7 +121,10 @@ const MembershipPreview = (props: { organization: OrganizationResource }) => { | |
| try { | ||
| await setActive({ | ||
| organization, | ||
| redirectUrl: redirectUrlComplete, | ||
| navigate: async () => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a small fix - atm the |
||
| // TODO(after-auth) ORGS-779 - Handle next tasks | ||
| await navigate(redirectUrlComplete); | ||
| }, | ||
| }); | ||
| } catch (err) { | ||
| if (!isClerkAPIResponseError(err)) { | ||
|
|
||
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.
💡 Verification agent
🧩 Analysis chain
Please add a regression test to cover the active→pending transition path
This behavior is critical for Next.js SSR protections. Add tests to assert:
You can search for other hook usages that might still be awaited (potentially causing similar issues) with this script:
🏁 Script executed:
Length of output: 25498
Add regression tests for
updateClientactive→pending transition and review other hook usagesPlease add a regression test in
packages/clerk-js/src/core/__tests__/clerk.test.tsto cover theactive→pendingtransition inupdateClient:onAfterSetActiveis called exactly once whensession.statuschanges from"active"to"pending"."active"or transitions"pending"→"pending".updateClientdoes not await the hook (i.e. it resolves before the hook’s returned promise).Additionally, I spotted two awaited invocations of
onAfterSetActiveinpackages/clerk-js/src/core/clerk.ts(around lines 532 and 1395). Please review those code paths to confirm whether they’re intentionally blocking or should also use a fire-and-forget pattern, and add tests or refactor as needed.🤖 Prompt for AI Agents