René's URL Explorer Experiment


Title: @clerk/expo v3 iOS: AuthView session not restored on cold start despite valid JWT in keychain (works on Android, same code) · Issue #8441 · clerk/javascript · GitHub

Open Graph Title: @clerk/expo v3 iOS: AuthView session not restored on cold start despite valid JWT in keychain (works on Android, same code) · Issue #8441 · clerk/javascript

X Title: @clerk/expo v3 iOS: AuthView session not restored on cold start despite valid JWT in keychain (works on Android, same code) · Issue #8441 · clerk/javascript

Description: Preliminary Checks I have reviewed the documentation: https://clerk.com/docs I have searched for existing issues: https://github.com/clerk/javascript/issues I have not already reached out to Clerk support via email or Discord This issue ...

Open Graph Description: Preliminary Checks I have reviewed the documentation: https://clerk.com/docs I have searched for existing issues: https://github.com/clerk/javascript/issues I have not already reached out to Clerk ...

X Description: Preliminary Checks I have reviewed the documentation: https://clerk.com/docs I have searched for existing issues: https://github.com/clerk/javascript/issues I have not already reached out to Clerk ...

Opengraph URL: https://github.com/clerk/javascript/issues/8441

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"@clerk/expo v3 iOS: AuthView session not restored on cold start despite valid JWT in keychain (works on Android, same code)","articleBody":"### Preliminary Checks\n\n- [x] I have reviewed the documentation: https://clerk.com/docs\n- [x] I have searched for existing issues: https://github.com/clerk/javascript/issues\n- [x] I have not already reached out to Clerk support via email or Discord\n- [x] This issue is not a question, general help request, or anything other than a bug report\n\n### Reproduction\n\nNo standalone repro repo, but reproduces in any Expo SDK 54 + `@clerk/expo` 3.2.7 app on iOS using `\u003cAuthView>` from `@clerk/expo/native`. We've reproduced it in two separate apps in our monorepo (one consumer app, one chat app) with completely different code.\n\n### Publishable key\n\n`pk_live_Y2xlcmsudGhlZGFzaHRhZy5jb20k`\n\n### Description\n\nAfter cold-start (force-quit + relaunch) on **iOS only**, the user's Clerk session is not restored from the JWT in `expo-secure-store`. The same code works perfectly on Android — sessions persist as expected.\n\nSymptoms: user sees the unauthenticated/sign-in screen on every app launch, even though `__clerk_client_jwt` is intact in keychain.\n\n### Environment\n\n| Component | Version |\n|---|---|\n| `@clerk/expo` | 3.2.7 (also reproduced on 3.2.8-canary.v20260501194208) |\n| `clerk-ios` (SwiftPM) | 1.0.0 |\n| Expo SDK | 54 |\n| React Native | 0.81 |\n| iOS (physical device) | 26.3.1 (iPhone 15 Pro Max) |\n| macOS | 26.3 |\n\n### Setup\n\n- `\u003cClerkProvider publishableKey={CLERK_PUBLISHABLE_KEY} tokenCache={tokenCache}>` (default `tokenCache` from `@clerk/expo/token-cache`)\n- `\u003cAuthView mode=\"signInOrUp\" />` from `@clerk/expo/native`\n- `useAuth({ treatPendingAsSignedOut: false })` everywhere\n- `@clerk/expo` plugin in `app.config.ts` plugins array\n- iOS bundle id `com.dashtag.app.dev`, signed with our developer cert\n\n### Diagnosis (with detailed traces)\n\nI patched `node_modules/@clerk/expo/dist/provider/ClerkProvider.js` to add console logging and isolated the bug to native `ClerkExpo.getSession()` returning `undefined` indefinitely after cold-start, despite `configure(pk, jwt)` resolving successfully and a valid JWT being passed.\n\n**Cold-start trace (consistent pattern):**\n\n```text\nmount | isSignedIn=undefined isLoaded=false jwt=eyJhbGciOiJSUzI1NiIs...(len 518)\nbootstrap: calling native configure with bearerToken= eyJhbGciOiJSUzI1NiIs...(len 518)\nbootstrap: configure resolved          ← native promise resolves cleanly\nmount | isSignedIn=false isLoaded=true ← Clerk JS finishes loading\nbootstrap: poll #1 getSession() -> undefined\nbootstrap: poll #5 getSession() -> undefined\nbootstrap: poll #15 getSession() -> undefined\nbootstrap: poll #30 getSession() -> undefined\nbootstrap: NO SESSION after 30 polls (3s timeout — original behavior)\n```\n\n**Workaround attempt #1 — extended polling 3s → 30s:** marginal improvement, not reliable.\n\n**Workaround attempt #2 — re-call `configure(pk, jwt)` repeatedly:** sometimes triggers eventual restore (~30% of attempts), but unreliable. After 60s of retries (20 × 3s intervals), `getSession()` still returns `undefined` for fresh sessions created moments before the test.\n\n**Workaround attempt #3 — block spurious `setActive({session: null})`:** never observed this code path being triggered; the bug is purely in `getSession()` returning null.\n\n### What's interesting\n\n1. **Same code, same JWT length, same Clerk user — works on Android, fails on iOS.** I tested side-by-side with the same Metro instance serving both an Android device and an iPhone using the exact same JS bundle. Android: session restored within 1-2s of cold start, every time. iOS: session restored maybe 30% of the time, often never.\n\n2. **The JWT in keychain is fresh and valid.** Just-created sessions (signed in moments before the test) fail to restore.\n\n3. **The `ClerkViewFactory.swift` `syncTokenState` logic looks suspect.** Lines 72-91 of `node_modules/@clerk/expo/ios/ClerkViewFactory.swift` compare the JS-keychain JWT against the `nativeDeviceToken` keychain entry; if they differ, `clearCachedClerkData()` is called to wipe `cachedClient` and `cachedEnvironment`. After the cache wipe, the SDK relies on a network round-trip to repopulate. If that round-trip is slow or fails silently, `Clerk.shared.session` stays nil and `getSession()` returns null. This iOS-specific keychain-dance code does not have an Android equivalent — which matches our observation that Android always works.\n\n4. The `configure()` promise resolving says nothing about whether the session is loaded. `Clerk.shared.session` might still be nil when `configure()` resolves.\n\n### Suggested fix\n\nEither:\n- Make `ClerkExpo.configure(pk, bearerToken)` not resolve until `Clerk.shared.session` is non-nil OR a definitive failure has occurred (currently `waitForLoadedSession()` polls but the promise resolves regardless).\n- Surface an `onAuthStateChange` event when the native SDK eventually loads the session post-`configure()`, so the JS bootstrap can react via `useNativeAuthEvents` instead of polling `getSession()`.\n- Avoid `clearCachedClerkData()` on cold-start when `existingToken == nil` (first-launch case) — only clear when the token actually changed and there's a stale cached client to reconcile.\n\n### Related issues\n\n- #8265 — `@clerk/expo` v3 session not restored on Metro JS reload (Android variant)\n- #8245 — `useAuth().isLoaded` permanently false in v3\n- Both confirm: `@clerk/clerk-expo` v2 did not have these regressions.\n","author":{"url":"https://github.com/brandonatdashtag","@type":"Person","name":"brandonatdashtag"},"datePublished":"2026-05-02T03:17:48Z","url":"https://github.com/clerk/javascript/issues/8441"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:64bc8734-8a59-4086-d4fd-65a240682fb5
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBFBC:15DF38:11C81E6:18331F4:6AFB6938
html-safe-nonceefd0efc2306f756c036c32055bab6d1963b5b01c4fe547facc8bc6f856808c72
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRkJDOjE1REYzODoxMUM4MUU2OjE4MzMxRjQ6NkFGQjY5MzgiLCJ2aXNpdG9yX2lkIjoiNjk5NTQ1NzMxOTc4MTQ5MzA0OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacb943264ac70e196bc14ef94cb41ac6c210df9b4e271829eb00a0d21b8f167dad
hovercard-subject-tagissue:4367728725
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/clerk/javascript/8441/issue_layout
twitter:imagehttps://opengraph.githubassets.com/1179d3c303eae3f692f454c675990bb88614d1e2c57ea8ba479e07ed04d49981/clerk/javascript/issues/8441
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/1179d3c303eae3f692f454c675990bb88614d1e2c57ea8ba479e07ed04d49981/clerk/javascript/issues/8441
og:image:altPreliminary Checks I have reviewed the documentation: https://clerk.com/docs I have searched for existing issues: https://github.com/clerk/javascript/issues I have not already reached out to Clerk ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamebrandonatdashtag
hostnamegithub.com
expected-hostnamegithub.com
Noneea33d13c96d0ff66bd8fa906b193d2213536b78cb06b0c50a4632c58b1418f94
turbo-cache-controlno-preview
go-importgithub.com/clerk/javascript git https://github.com/clerk/javascript.git
octolytics-dimension-user_id49538330
octolytics-dimension-user_loginclerk
octolytics-dimension-repository_id438331492
octolytics-dimension-repository_nwoclerk/javascript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id438331492
octolytics-dimension-repository_network_root_nwoclerk/javascript
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release59ef97164c52cf59bd10558ddec9c4f482763988
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/clerk/javascript/issues/8441#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fclerk%2Fjavascript%2Fissues%2F8441
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fclerk%2Fjavascript%2Fissues%2F8441
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=clerk%2Fjavascript
Reloadhttps://github.com/clerk/javascript/issues/8441
Reloadhttps://github.com/clerk/javascript/issues/8441
Reloadhttps://github.com/clerk/javascript/issues/8441
clerkhttps://github.com/clerk
javascripthttps://github.com/clerk/javascript
Codehttps://github.com/clerk/javascript
Issues45 (45)https://github.com/clerk/javascript/issues
Pull requests110 (110)https://github.com/clerk/javascript/pulls
Discussionshttps://github.com/clerk/javascript/discussions
Actionshttps://github.com/clerk/javascript/actions
Security and quality6 (6)https://github.com/clerk/javascript/security
Insightshttps://github.com/clerk/javascript/pulse
https://github.com/clerk/javascript
New issuehttps://github.com/login?return_to=https://github.com/clerk/javascript/issues/8441
New issuehttps://github.com/login?return_to=https://github.com/clerk/javascript/issues/8441
@clerk/expo v3 iOS: AuthView session not restored on cold start despite valid JWT in keychain (works on Android, same code)https://github.com/clerk/javascript/issues/8441#top
https://github.com/chriscanin
https://github.com/brandonatdashtag
brandonatdashtaghttps://github.com/brandonatdashtag
on May 2, 2026https://github.com/clerk/javascript/issues/8441#issue-4367728725
https://clerk.com/docshttps://clerk.com/docs
https://github.com/clerk/javascript/issueshttps://github.com/clerk/javascript/issues
#1https://github.com/clerk/javascript/pull/1
#2https://github.com/clerk/javascript/pull/2
#3https://github.com/clerk/javascript/pull/3
@clerk/expo v3: Session not restored on Metro JS reload on Android despite valid JWT in tokenCache #8265https://github.com/clerk/javascript/issues/8265
@clerk/expo v3: useAuth().isLoaded permanently false - works in minimal app, fails in real app (physical device + simulator) #8245https://github.com/clerk/javascript/issues/8245
https://github.com/chriscanin
chriscaninhttps://github.com/chriscanin
on May 5, 2026https://github.com/clerk/javascript/issues/8441#issuecomment-4380795972
@brandonatdashtaghttps://github.com/brandonatdashtag
#8469https://github.com/clerk/javascript/pull/8469
https://github.com/brandonatdashtag
brandonatdashtaghttps://github.com/brandonatdashtag
on May 5, 2026https://github.com/clerk/javascript/issues/8441#issuecomment-4380834201
@chriscaninhttps://github.com/chriscanin
jacekradkohttps://github.com/jacekradko
chriscaninhttps://github.com/chriscanin
on May 5, 2026https://github.com/clerk/javascript/issues/8441#event-25191131458
https://github.com/chriscanin
chriscaninhttps://github.com/chriscanin
on May 6, 2026https://github.com/clerk/javascript/issues/8441#issuecomment-4392431641
@brandonatdashtaghttps://github.com/brandonatdashtag
version 3.2.7https://www.npmjs.com/package/@clerk/expo/v/3.2.7
https://github.com/brandonatdashtag
brandonatdashtaghttps://github.com/brandonatdashtag
on May 7, 2026https://github.com/clerk/javascript/issues/8441#issuecomment-4393794247
@chriscaninhttps://github.com/chriscanin
https://github.com/brandonatdashtag
brandonatdashtaghttps://github.com/brandonatdashtag
on May 7, 2026https://github.com/clerk/javascript/issues/8441#issuecomment-4393869984
@chriscaninhttps://github.com/chriscanin
chriscaninhttps://github.com/chriscanin
completedhttps://github.com/clerk/javascript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on May 18, 2026https://github.com/clerk/javascript/issues/8441#event-25670811174
Sign up for freehttps://github.com/signup?return_to=https://github.com/clerk/javascript/issues/8441
Sign in to commenthttps://github.com/login?return_to=https://github.com/clerk/javascript/issues/8441
chriscaninhttps://github.com/chriscanin
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.