Skip to content

fix(clerk-js): Restore internal queryClient for backward compat with older SDKs#8562

Merged
wobsoriano merged 2 commits into
mainfrom
rob/revert-internal-query-client
May 15, 2026
Merged

fix(clerk-js): Restore internal queryClient for backward compat with older SDKs#8562
wobsoriano merged 2 commits into
mainfrom
rob/revert-internal-query-client

Conversation

@wobsoriano
Copy link
Copy Markdown
Member

Description

clerk-js@6.11.0 removed clerk.__internal_queryClient as part of #8434, which moved QueryClient ownership into @clerk/shared. However, apps still on @clerk/shared < 4.10.0 rely on that getter to initialize TanStack Query. With clerk-js auto-updating from the CDN, those apps started seeing useOrganizationList and useOrganization return empty data with no network request.

This PR restores the getter as a backward compat shim:

Behavior

  • Updated SDKs (@clerk/shared >= 4.10.0): no change, getter is never accessed, chunk is never fetched
  • Older SDKs (@clerk/shared < 4.10.0): getter works again, queries fire, data loads

Test plan

  • 4 new tests covering initial undefined state, post-resolve shape, instance stability, and queryClientStatus event emission
  • Full @clerk/clerk-js test suite passes (722 tests)

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 15, 2026

🦋 Changeset detected

Latest commit: d328a48

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

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/expo 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

@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 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 May 15, 2026 8:46pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 15, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: b4932e68-7a54-429d-acd2-64cb7d83ec3a

📥 Commits

Reviewing files that changed from the base of the PR and between 74dca0b and d328a48.

📒 Files selected for processing (3)
  • .changeset/restore-internal-query-client.md
  • packages/clerk-js/bundlewatch.config.json
  • packages/clerk-js/src/core/__tests__/clerk.internal-query-client.test.ts
✅ Files skipped from review due to trivial changes (2)
  • .changeset/restore-internal-query-client.md
  • packages/clerk-js/bundlewatch.config.json

📝 Walkthrough

Walkthrough

This PR restores a backward-compatible internal React Query client on Clerk via a new lazy-loading getter __internal_queryClient. It adds a re-export module for QueryClient, a private field and getter on Clerk that dynamically imports and instantiates QueryClient, emits queryClientStatus when ready, and caches the instance. Build changes add @tanstack/query-core, configure Rspack to split it into a query-core-vendors chunk, and update bundlewatch thresholds. Tests exercise lazy initialization, singleton behavior, and event emission.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: restoring an internal queryClient getter as a backward compatibility shim after it was removed in a previous version.
Description check ✅ Passed The description provides relevant context about the change, explaining why the getter was removed, why it needs to be restored, and how the implementation addresses backward compatibility concerns.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 15, 2026

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8562

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: d328a48

…ent shim

- Use void to discard getter expressions in tests (no-unused-expressions)
- Add patch changeset for @clerk/clerk-js
- Bump clerk.js (543->549KB) and clerk.no-rhc.js (311->316KB) for the
  query-core dynamic-import infrastructure re-added by the shim
@wobsoriano wobsoriano merged commit 692b68d into main May 15, 2026
43 checks passed
@wobsoriano wobsoriano deleted the rob/revert-internal-query-client branch May 15, 2026 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants