Skip to content

Commit 78b41dd

Browse files
committed
fix(expo): defer NativeSessionSync flag until sync actually succeeds
Move hasSyncedRef assignment into syncToNative so the guard flag is only set after confirming native already has a session or after successfully pushing the bearer token. Previously the flag was set synchronously before the async work, preventing retries on failure.
1 parent edd9d86 commit 78b41dd

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/expo/src/provider/ClerkProvider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ function NativeSessionSync({
8585
return;
8686
}
8787

88-
hasSyncedRef.current = true;
89-
9088
const syncToNative = async () => {
9189
try {
9290
const ClerkExpo = NativeClerkModule;
@@ -102,13 +100,15 @@ function NativeSessionSync({
102100
const hasNativeSession = !!(nativeSession?.sessionId || nativeSession?.session?.id);
103101

104102
if (hasNativeSession) {
103+
hasSyncedRef.current = true;
105104
return;
106105
}
107106

108107
// Read the JS SDK's client JWT and push it to the native SDK
109108
const bearerToken = (await effectiveTokenCache?.getToken(CLERK_CLIENT_JWT_KEY)) ?? null;
110109
if (bearerToken) {
111110
await ClerkExpo.configure(publishableKey, bearerToken);
111+
hasSyncedRef.current = true;
112112
}
113113
} catch (error) {
114114
if (__DEV__) {

0 commit comments

Comments
 (0)