René's URL Explorer Experiment


Title: @clerk/expo: useSSO/useOAuth dynamic import() of expo-auth-session/expo-web-browser fails under Metro, masked by empty catch · Issue #8288 · clerk/javascript · GitHub

Open Graph Title: @clerk/expo: useSSO/useOAuth dynamic import() of expo-auth-session/expo-web-browser fails under Metro, masked by empty catch · Issue #8288 · clerk/javascript

X Title: @clerk/expo: useSSO/useOAuth dynamic import() of expo-auth-session/expo-web-browser fails under Metro, masked by empty catch · Issue #8288 · clerk/javascript

Description: Summary useSSO / useOAuth in @clerk/expo use a dynamic import() for expo-auth-session and expo-web-browser wrapped in an empty catch {}. When Metro's async-chunk resolution fails (not uncommon in monorepo / bun setups, or when @expo/metr...

Open Graph Description: Summary useSSO / useOAuth in @clerk/expo use a dynamic import() for expo-auth-session and expo-web-browser wrapped in an empty catch {}. When Metro's async-chunk resolution fails (not uncommon in m...

X Description: Summary useSSO / useOAuth in @clerk/expo use a dynamic import() for expo-auth-session and expo-web-browser wrapped in an empty catch {}. When Metro's async-chunk resolution fails (not uncommon ...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"@clerk/expo: useSSO/useOAuth dynamic import() of expo-auth-session/expo-web-browser fails under Metro, masked by empty catch","articleBody":"## Summary\n\n`useSSO` / `useOAuth` in `@clerk/expo` use a dynamic `import()` for `expo-auth-session` and `expo-web-browser` wrapped in an empty `catch {}`. When Metro's async-chunk resolution fails (not uncommon in monorepo / bun setups, or when `@expo/metro-runtime` isn't imported at the entry), every underlying error is swallowed and surfaces as the misleading:\n\n> expo-auth-session and expo-web-browser are required for SSO. Install them: npx expo install expo-auth-session expo-web-browser\n\n…even though both packages are installed, listed in `package.json`, and being bundled by Metro.\n\n## Offending code\n\n`packages/expo/src/hooks/useSSO.ts` (built as `dist/hooks/useSSO.js`):\n\n```js\nlet AuthSession;\nlet WebBrowserModule;\ntry {\n  [AuthSession, WebBrowserModule] = await Promise.all([\n    import(\"expo-auth-session\"),\n    import(\"expo-web-browser\"),\n  ]);\n} catch {\n  return errorThrower.throw(\n    \"expo-auth-session and expo-web-browser are required for SSO. Install them: npx expo install expo-auth-session expo-web-browser\"\n  );\n}\n```\n\nTwo problems:\n\n1. **Dynamic `import()` from a published bundle is fragile under Metro.** It forces Metro to emit async chunks; if the runtime loader isn't set up (e.g. `@expo/metro-runtime` not imported), the promise rejects and the real error never surfaces. A synchronous `require()` would be bundled into the main chunk and \"just work\". This is the same class of issue fixed for the RN QueryClient in clerk/javascript#8087 — dynamic import from inside the published bundle broken under Metro, sync setup resolves it.\n2. **`catch {}` hides the real error.** Even when the underlying failure is `Unable to resolve module`, `@expo/metro-runtime is not installed`, or a genuine `TypeError`, users see a generic \"install these packages\" message that sends them in the wrong direction.\n\n## Environment\n\n- `@clerk/expo@3.1.9`\n- Expo SDK 55 (`expo@^55.0.11`, `expo-router@~55.0.10`)\n- Metro (default `@expo/metro-config`)\n- `expo-auth-session@~55.0.13`, `expo-web-browser@~55.0.14` both installed\n- bun workspaces monorepo\n- iOS (dev client + simulator)\n\n## Repro\n\n1. Bun-workspaces monorepo, `@clerk/expo` + `expo-auth-session` + `expo-web-browser` all correctly declared in `apps/mobile/package.json`.\n2. Don't import `@expo/metro-runtime` at the entry (it's not a declared dep of `@clerk/expo` or `expo-router` in this setup, so it's easy to miss).\n3. Call `startSSOFlow({ strategy: 'oauth_google' })` from a screen.\n4. Metro logs show both packages bundling successfully:\n\n   ```\n   iOS Bundled 321ms …/expo-auth-session/build/index.js (1018 modules)\n   iOS Bundled 347ms …/expo-web-browser/build/WebBrowser.js (1145 modules)\n   ```\n\n5. At runtime, the dynamic `import()` inside `useSSO` rejects and Clerk throws the \"required for SSO\" error.\n\nRoot cause in our case: `@expo/metro-runtime` wasn't imported at the app entry, so async chunks produced by Metro couldn't be loaded. Adding `import '@expo/metro-runtime'` at the top of the root layout fixed the runtime loading — but only after hours of wrong turns because the Clerk error pointed at package installation, not bundler/runtime.\n\n## Current workaround\n\nWe ship a `postinstall` patch that rewrites the dynamic imports to `require()`:\n\n```js\n// scripts/patch-clerk-expo-sso.mjs\nconst SNIPPET_FROM =\n  '[AuthSession, WebBrowserModule] = await Promise.all([import(\"expo-auth-session\"), import(\"expo-web-browser\")]);';\nconst SNIPPET_TO = `AuthSession = require(\"expo-auth-session\");\n      WebBrowserModule = require(\"expo-web-browser\");`;\n```\n\nApplied to `node_modules/@clerk/expo/dist/hooks/useSSO.js` and `useOAuth.js`. This eliminates the problem entirely on native because Metro inlines both modules into the main bundle instead of emitting async chunks.\n\n## Proposed fix\n\nEither (or both):\n\n1. **Prefer synchronous `require()` on native** (same spirit as clerk/javascript#8087). `expo-auth-session` / `expo-web-browser` are tiny and already listed as optional peer deps — nothing is gained by deferring them. `require()` is Metro-safe and removes the async-chunk failure mode entirely.\n\n2. **At minimum, surface the real error:**\n\n   ```js\n   try {\n     [AuthSession, WebBrowserModule] = await Promise.all([\n       import(\"expo-auth-session\"),\n       import(\"expo-web-browser\"),\n     ]);\n   } catch (e) {\n     return errorThrower.throw(\n       \\`expo-auth-session and expo-web-browser are required for SSO. If they are installed, this usually means Metro failed to resolve the dynamic import() — ensure \\\\\\`@expo/metro-runtime\\\\\\` is imported at your app entry. Underlying error: \\${e?.message ?? e}\\`\n     );\n   }\n   ```\n\n   The `catch {}` is actively hostile to debugging — it converts every possible failure mode (bundler, runtime, native module, version mismatch) into a single wrong-suggestion error.\n\nHappy to open a PR if the direction is agreed.\n\n## Related\n\n- clerk/javascript#8087 — `fix(expo): synchronous QueryClient for React Native` (same class of dynamic-import-in-Metro fix)","author":{"url":"https://github.com/sethwebster","@type":"Person","name":"sethwebster"},"datePublished":"2026-04-11T03:48:24Z","url":"https://github.com/clerk/javascript/issues/8288"}

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:b94e5a93-5fe0-543d-d62f-79abe260c9f9
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE1C0:3D6EF:7FC6B8:B400E2:6AFB6CF8
html-safe-noncee8e9d5a3de39d741622029ed32506659ced7b7df79db841a0f24bb48ee1a0957
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMUMwOjNENkVGOjdGQzZCODpCNDAwRTI6NkFGQjZDRjgiLCJ2aXNpdG9yX2lkIjoiNTcwNjIyMDYzMTMwNTcxMDg0MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmaccbe95bbe27dda871a27b0b192ad0d1e18a6f02a2c02eeb84422ea20669f9d8f2
hovercard-subject-tagissue:4242926656
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/8288/issue_layout
twitter:imagehttps://opengraph.githubassets.com/7e64782e6707c0e0e193c9a7d23a8e8d3651a37a8ec4e32891bea4c4b031a59f/clerk/javascript/issues/8288
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7e64782e6707c0e0e193c9a7d23a8e8d3651a37a8ec4e32891bea4c4b031a59f/clerk/javascript/issues/8288
og:image:altSummary useSSO / useOAuth in @clerk/expo use a dynamic import() for expo-auth-session and expo-web-browser wrapped in an empty catch {}. When Metro's async-chunk resolution fails (not uncommon in m...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesethwebster
hostnamegithub.com
expected-hostnamegithub.com
Nonecca289ecd54650fcf3c0b037a58b97186dee2cc4406819d87fab93728fd83700
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
release88808b1fae5ab8a526a73e7ce5542a10eb9d6971
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/clerk/javascript/issues/8288#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fclerk%2Fjavascript%2Fissues%2F8288
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%2F8288
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/8288
Reloadhttps://github.com/clerk/javascript/issues/8288
Reloadhttps://github.com/clerk/javascript/issues/8288
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/8288
New issuehttps://github.com/login?return_to=https://github.com/clerk/javascript/issues/8288
#8720https://github.com/clerk/javascript/pull/8720
@clerk/expo: useSSO/useOAuth dynamic import() of expo-auth-session/expo-web-browser fails under Metro, masked by empty catchhttps://github.com/clerk/javascript/issues/8288#top
#8720https://github.com/clerk/javascript/pull/8720
https://github.com/sethwebster
sethwebsterhttps://github.com/sethwebster
on Apr 11, 2026https://github.com/clerk/javascript/issues/8288#issue-4242926656
fix(expo): synchronous QueryClient for React Native #8087https://github.com/clerk/javascript/pull/8087
fix(expo): synchronous QueryClient for React Native #8087https://github.com/clerk/javascript/pull/8087
fix(expo): synchronous QueryClient for React Native #8087https://github.com/clerk/javascript/pull/8087
https://github.com/apps/github-actions
github-actionshttps://github.com/apps/github-actions
on May 12, 2026https://github.com/clerk/javascript/issues/8288#issuecomment-4426202842
GitHub Actionshttps://help.github.com/en/actions
contributing guidehttps://github.com/clerk/javascript/blob/main/docs/CONTRIBUTING.md
github-actionshttps://github.com/apps/github-actions
Stalehttps://github.com/clerk/javascript/issues?q=state%3Aopen%20label%3A%22Stale%22
on May 12, 2026https://github.com/clerk/javascript/issues/8288#event-25407645804
jacekradkohttps://github.com/jacekradko
chriscaninhttps://github.com/chriscanin
on May 13, 2026https://github.com/clerk/javascript/issues/8288#event-25501575215
jacekradkohttps://github.com/jacekradko
Stalehttps://github.com/clerk/javascript/issues?q=state%3Aopen%20label%3A%22Stale%22
on May 13, 2026https://github.com/clerk/javascript/issues/8288#event-25501576891
wobsorianohttps://github.com/wobsoriano
chriscaninhttps://github.com/chriscanin
on Jun 1, 2026https://github.com/clerk/javascript/issues/8288#event-26209645139
wobsorianohttps://github.com/wobsoriano
completedhttps://github.com/clerk/javascript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#8720https://github.com/clerk/javascript/pull/8720
on Jun 3, 2026https://github.com/clerk/javascript/issues/8288#event-26302188647
https://github.com/wobsoriano
wobsorianohttps://github.com/wobsoriano
on Jun 3, 2026https://github.com/clerk/javascript/issues/8288#issuecomment-4616240280
Sign up for freehttps://github.com/signup?return_to=https://github.com/clerk/javascript/issues/8288
Sign in to commenthttps://github.com/login?return_to=https://github.com/clerk/javascript/issues/8288
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.