Conversation
🦋 Changeset detectedLatest commit: 2c09e1e The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
|
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: |
|
|
||
| describe('with offline browser and network failure', () => { | ||
| beforeEach(() => { | ||
| // Use real timers for offline tests to avoid unhandled rejection issues with retry logic |
d134aeb to
c230146
Compare
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a changeset entry for a patch release. Updates 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
992a3ba to
2377201
Compare
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/clerk-js/src/core/resources/Session.ts`:
- Around line 451-453: The token-update path currently emits and caches/clears
when isValidBrowserOnline() is true even if cachedToken.getRawString() is empty;
change the guard so eventBus.emit(events.TokenUpdate, { token: cachedToken })
and any code that writes/clears __session only run when
cachedToken.getRawString() is truthy (i.e., require a non-empty token), and do
not rely on isValidBrowserOnline() as a substitute for a missing token. Apply
this same change to the other TokenUpdate/caching occurrences that use
cachedToken.getRawString() || isValidBrowserOnline() so all places (the
eventBus.emit call and the __session write/clear logic) first check
cachedToken.getRawString() before proceeding.
ℹ️ Review info
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
packages/clerk-js/src/core/resources/Session.tspackages/clerk-js/src/core/resources/__tests__/Session.test.ts
745dbbe to
2c09e1e
Compare
| // navigator.onLine is the standard API and is reliable for detecting | ||
| // complete disconnection (airplane mode, WiFi off, etc.). | ||
| // The experimental navigator.connection API (rtt/downlink) was previously | ||
| // used as a secondary signal, but it reports zero values in headless browsers | ||
| // and CI environments even when connected, causing false offline detection. | ||
| return !!navigator.onLine; |
There was a problem hiding this comment.
hmm, I'm not sure we want to change this. can we look back in the history? I feel like I recall there being issues with only relying on navigator.onLine in the past
There was a problem hiding this comment.
I couldn't find something concrete - the main difference is that navigator.onLine can return true even when there's no actual internet connectivity (it only detects whether the device is connected to a network, for example a wifi network with no internet access).
navigator.connection seems like a better signal but it's more unreliable as it's not supported on Firefox or Safari at all, in headless browsers it reports navigator.connection.rtt == 0 and I found other issues around the web as well.
This seems the better fix and we can always iterate. WDYT?
Description
When offline, two code paths in
Session.tsemittoken:updateevents with empty tokens.AuthCookieServiceinterprets empty tokens as signed-out and removes the__session cookie— even though the session is still valid server-side. On the next page load or visibility change, the missing cookie makes the user appear signed out.Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
Bug Fixes
Tests
Chores