fix(shared): avoid false offline detection in React Native#8084
fix(shared): avoid false offline detection in React Native#8084eliotgevers wants to merge 6 commits intoclerk:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 3adcdb1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 21 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@eliotgevers is attempting to deploy a commit to the Clerk Production Team on Vercel. A member of the Team first needs to authorize it. |
|
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)
📝 WalkthroughWalkthroughisBrowserOnline was updated to return true when 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📝 Coding Plan
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 CodeRabbit can use Trivy to scan for security misconfigurations and secrets in Infrastructure as Code files.Add a .trivyignore file to your project to customize which findings Trivy reports. |
chriscanin
left a comment
There was a problem hiding this comment.
Tested and looking good. Setting this to approved.
Summary
This fixes false offline detection in React Native / Expo when
navigator.onLineis not implemented.session.getToken({ skipCache: true })goes through the forced-refresh path, which checks the shared online helper before fetching a fresh token. In React Native,windowandnavigatorexist, butnavigator.onLinedoes not, so the current logic treats the runtime as offline and throwsClerkOfflineError.This change treats React Native, and runtimes without a boolean
navigator.onLine, as online/unknown rather than offline. Actual network failures still surface through the normal fetch path.Changes
truefromisBrowserOnline()for React Nativetruewhennavigator.onLineis not implemented as a boolean@clerk/sharedValidation
pnpm --filter @clerk/shared test -- src/__tests__/browser.spec.tsFixes #8083
Summary by CodeRabbit
Bug Fixes
Tests