Skip to content

Commit 5080135

Browse files
authored
Merge branch 'main' into renovate/npm-astro-vulnerability
2 parents dc33c4d + 1c27d4d commit 5080135

21 files changed

Lines changed: 247 additions & 165 deletions

.changeset/ci-ready-for-review.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@clerk/expo': patch
3+
---
4+
5+
Fix session loss on Expo JS reload (pressing R in dev)
6+
7+
`NativeSessionSync` was calling native `signOut()` during the loading phase when `isSignedIn` is `undefined`. On a JS reload, the native module persists from the previous session, so `signOut()` revokes the session server-side and clears all keychain items, forcing the user to log in again. This adds an `isLoaded` guard so native `signOut()` is only called when Clerk has confirmed the user is actually signed out.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@clerk/shared': patch
3+
'@clerk/clerk-js': patch
4+
'@clerk/react': patch
5+
---
6+
7+
Move ownership of the clerk-rq `QueryClient` from `@clerk/clerk-js` into `@clerk/shared`. The `QueryObserver` (constructed in `@clerk/shared`) and the `Query` objects it observes now always come from a single `@tanstack/query-core` resolution — the cross-bundle API contract that produced #8428 (`Query.isFetched is not a function`) no longer exists.
8+
9+
This removes the undocumented `clerk.__internal_queryClient` getter from both `@clerk/clerk-js` and `@clerk/react`'s `IsomorphicClerk`. The `QueryClient` is owned by an internal singleton in `@clerk/shared`, lazily instantiated on the browser only — server renders return `undefined`, preserving SSR safety and avoiding cross-request cache sharing.
10+
11+
`@tanstack/query-core` is no longer a direct dependency of `@clerk/clerk-js`; it remains a dep of `@clerk/shared` and resolves consumer-side as before.

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: CI
33
on:
44
merge_group:
55
pull_request:
6+
types: [opened, synchronize, reopened, ready_for_review]
67
branches:
78
- main
89
- release/v4

packages/clerk-js/bundlewatch.config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
{ "path": "./dist/coinbase*.js", "maxSize": "36KB" },
1010
{ "path": "./dist/base-account-sdk*.js", "maxSize": "203KB" },
1111
{ "path": "./dist/stripe-vendors*.js", "maxSize": "1KB" },
12-
{ "path": "./dist/query-core-vendors*.js", "maxSize": "11KB" },
1312
{ "path": "./dist/zxcvbn-ts-core*.js", "maxSize": "12KB" },
1413
{ "path": "./dist/zxcvbn-common*.js", "maxSize": "226KB" }
1514
]

packages/clerk-js/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@
9191
"@solana/wallet-standard": "catalog:module-manager",
9292
"@stripe/stripe-js": "5.6.0",
9393
"@swc/helpers": "catalog:repo",
94-
"@tanstack/query-core": "catalog:repo",
9594
"@wallet-standard/core": "catalog:module-manager",
9695
"@zxcvbn-ts/core": "catalog:module-manager",
9796
"@zxcvbn-ts/language-common": "catalog:module-manager",

packages/clerk-js/rspack.config.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,6 @@ const common = ({ mode, variant, disableRHC = false }) => {
110110
chunks: 'all',
111111
enforce: true,
112112
},
113-
queryCoreVendor: {
114-
test: /[\\/]node_modules[\\/](@tanstack\/query-core)[\\/]/,
115-
name: 'query-core-vendors',
116-
chunks: 'all',
117-
enforce: true,
118-
},
119113
defaultVendors: {
120114
minChunks: 1,
121115
test: module => {

packages/clerk-js/src/core/clerk.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ import type {
138138
import type { ClerkUI } from '@clerk/shared/ui';
139139
import { addClerkPrefix, isAbsoluteUrl, stripScheme } from '@clerk/shared/url';
140140
import { allSettled, handleValueOrFn, noop } from '@clerk/shared/utils';
141-
import type { QueryClient } from '@tanstack/query-core';
142141

143142
import { debugLogger, initDebugLogger } from '@/utils/debug';
144143
import { ModuleManager } from '@/utils/moduleManager';
@@ -248,7 +247,6 @@ export class Clerk implements ClerkInterface {
248247
// converted to protected environment to support `updateEnvironment` type assertion
249248
protected environment?: EnvironmentResource | null;
250249

251-
#queryClient: QueryClient | undefined;
252250
#publishableKey = '';
253251
#domain: DomainOrProxyUrl['domain'];
254252
#proxyUrl: DomainOrProxyUrl['proxyUrl'];
@@ -268,28 +266,6 @@ export class Clerk implements ClerkInterface {
268266
#touchThrottledUntil = 0;
269267
#publicEventBus = createClerkEventBus();
270268

271-
get __internal_queryClient(): { __tag: 'clerk-rq-client'; client: QueryClient } | undefined {
272-
if (!this.#queryClient) {
273-
void import('./query-core')
274-
.then(module => module.QueryClient)
275-
.then(QueryClient => {
276-
if (this.#queryClient) {
277-
return;
278-
}
279-
this.#queryClient = new QueryClient();
280-
// @ts-expect-error - queryClientStatus is not typed
281-
this.#publicEventBus.emit('queryClientStatus', 'ready');
282-
});
283-
}
284-
285-
return this.#queryClient
286-
? {
287-
__tag: 'clerk-rq-client',
288-
client: this.#queryClient,
289-
}
290-
: undefined;
291-
}
292-
293269
public __internal_getCachedResources:
294270
| (() => Promise<{ client: ClientJSONSnapshot | null; environment: EnvironmentJSONSnapshot | null }>)
295271
| undefined;

packages/clerk-js/src/core/query-core.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/clerk-js/src/test/mock-helpers.ts

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { __createClerkTestQueryClient } from '@clerk/shared/react';
12
import type { ActiveSessionResource, LoadedClerk } from '@clerk/shared/types';
23
import { type Mocked, vi } from 'vitest';
34

4-
import { QueryClient } from '../core/query-core';
55
import type { RouteContextValue } from '../ui/router';
66

77
type FunctionLike = (...args: any) => any;
@@ -46,19 +46,7 @@ export const mockClerkMethods = (clerk: LoadedClerk): DeepVitestMocked<LoadedCle
4646
// Cast clerk to any to allow mocking properties
4747
const clerkAny = clerk as any;
4848

49-
const defaultQueryClient = {
50-
__tag: 'clerk-rq-client' as const,
51-
client: new QueryClient({
52-
defaultOptions: {
53-
queries: {
54-
retry: false,
55-
// Setting staleTime to Infinity will not cause issues between tests as long as each test
56-
// case has its own wrapper that initializes a Clerk instance with a new QueryClient.
57-
staleTime: Infinity,
58-
},
59-
},
60-
}),
61-
};
49+
__createClerkTestQueryClient();
6250

6351
mockMethodsOf(clerkAny);
6452
if (clerkAny.client) {
@@ -92,12 +80,6 @@ export const mockClerkMethods = (clerk: LoadedClerk): DeepVitestMocked<LoadedCle
9280
mockMethodsOf(clerkAny.billing);
9381
}
9482

95-
// Mock the __internal_queryClient getter property
96-
Object.defineProperty(clerkAny, '__internal_queryClient', {
97-
get: vi.fn(() => defaultQueryClient),
98-
configurable: true,
99-
});
100-
10183
mockProp(clerkAny, 'navigate');
10284
mockProp(clerkAny, 'setActive');
10385
mockProp(clerkAny, 'redirectWithAuth');

0 commit comments

Comments
 (0)