fix(clerk-js): Prevent infinite polling loop on invalid dev browser token#7951
fix(clerk-js): Prevent infinite polling loop on invalid dev browser token#7951
Conversation
…s invalid When the __clerk_db_jwt dev browser token becomes invalid during runtime, the token refresh request returns dev_browser_unauthenticated. Previously, this error was treated as a general 401, triggering handleUnauthenticated which calls Client.fetch, which also fails with 401, creating an infinite recursion loop until rate-limited. This fix intercepts dev_browser_unauthenticated errors at the _baseFetch level and calls __internal_handleUnauthenticatedDevBrowser to refresh the dev browser token instead of entering the session-level sign-out flow. The poller then retries with the fresh dev browser token on its next tick. Also adds an integration test that verifies dev browser refresh occurs without excessive /v1/client requests (the sign of the infinite loop). Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 3dbaee9 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.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds handling for 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
@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: |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Description
Fixes infinite polling loop that occurs when the
__clerk_db_jwtdev browser token becomes invalid during runtime. When the token refresh request returnsdev_browser_unauthenticated, it was previously treated as a general 401 error, triggeringhandleUnauthenticatedwhich callsClient.fetch, creating an infinite recursion loop until rate-limited.The fix intercepts
dev_browser_unauthenticatederrors in_baseFetchand calls__internal_handleUnauthenticatedDevBrowserto refresh the dev browser token instead of entering the session-level sign-out flow.Includes an integration test that verifies dev browser refresh occurs without excessive
/v1/clientrequests (which would indicate the infinite loop).Checklist
pnpm testruns as expected (all unit tests pass, integration test passes)pnpm buildruns as expectedType of change
Summary by CodeRabbit