fix(expo): migrate useSSO to core-3 and fix browser dismissal for OAuth/SSO flows#8140
fix(expo): migrate useSSO to core-3 and fix browser dismissal for OAuth/SSO flows#8140chriscanin wants to merge 2 commits intomainfrom
Conversation
…th/SSO flows - Replace legacy useSignIn/useSignUp imports with core-3 useClerk/useSignIn - Use clerk.client.signIn.reload() with nonce + clerk.setActive() instead of legacy setActive - Add dismissBrowser() in finally block for both useSSO and useOAuth to prevent browser lingering - Handle session_exists errors by clearing stale JWT from SecureStore and retrying - Simplify return type: hook handles session activation internally, callers no longer need setActive
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughIn In 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can customize the high-level summary generated by CodeRabbit.Configure the |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/expo/src/hooks/useSSO.ts`:
- Around line 70-85: Replace the incorrect post-call error-checking of
signIn.create (which uses createResult.error) with a try/catch around the await
signIn.create(createParams) call: call signIn.create inside try, and in catch
inspect the thrown error (using isClerkAPIResponseError(error) and checking
error.errors.some(e => e.code === 'session_exists') or
error.message?.includes('already signed in')); if it's a session_exists /
already-signed-in case, call SecureStore.deleteItemAsync(CLERK_CLIENT_JWT_KEY)
and retry signIn.create(createParams), otherwise rethrow the error; if the retry
fails, rethrow that error as well. Ensure you update any references to
createResult to work with the try/catch flow.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: ASSERTIVE
Plan: Pro
Run ID: f7ab895d-0578-4bb7-92d4-aa44d8e84c89
📒 Files selected for processing (2)
packages/expo/src/hooks/useOAuth.tspackages/expo/src/hooks/useSSO.ts
Summary
Fixes the SSO/OAuth flow in
useSSOanduseOAuthfor Expo:useSSOfrom legacy to core-3 API — replacesuseSignIn/useSignUpfrom@clerk/react/legacywithuseClerk/useSignInfrom@clerk/reactopenAuthSessionAsyncin try/finally withawait dismissBrowser()to prevent the in-app browser from lingering in the background after auth completes, which caused subsequent SSO attempts to fail or appear frozen (reported by community user Erwin)session_exists/ "already signed in" errors fromsignIn.create()by clearing the stale JWT from SecureStore and retrying, so users don't get stuck after sign-out → sign-in cyclesclerk.setActive(), callers no longer need to callsetActivethemselvesBefore (app code)
After (app code)
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit