fix(react): Fix stale SSR state during cross-tab sign-out#7865
fix(react): Fix stale SSR state during cross-tab sign-out#7865
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: c683ba9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
@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. 🎉 📝 WalkthroughWalkthroughThis pull request adds deduplication for App Router navigations in 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.changeset/dry-mangos-fail.md (1)
5-5: Consider adding cross-tab scenario context.The description is clear and technically accurate. For enhanced user understanding, you could optionally mention the specific cross-tab scenario (e.g., "when signing out in one browser tab while other tabs remain open").
📝 Optional enhancement for user clarity
-Fix navigation hang on cross-tab sign-out by preventing stale SSR state from being used after sign-out detection. +Fix navigation hang when signing out in one browser tab while other authenticated tabs remain open, by preventing stale SSR state from being used after sign-out detection.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.changeset/dry-mangos-fail.md at line 5, Update the changeset description "Fix navigation hang on cross-tab sign-out by preventing stale SSR state from being used after sign-out detection." to explicitly mention the cross-tab scenario (for example: "when signing out in one browser tab while other tabs remain open") so users immediately understand the context; keep the technical explanation about preventing stale SSR state after sign-out detection (the existing phrase) and append a short example clause referencing the cross-tab sign-out behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.changeset/dry-mangos-fail.md:
- Line 5: Update the changeset description "Fix navigation hang on cross-tab
sign-out by preventing stale SSR state from being used after sign-out
detection." to explicitly mention the cross-tab scenario (for example: "when
signing out in one browser tab while other tabs remain open") so users
immediately understand the context; keep the technical explanation about
preventing stale SSR state after sign-out detection (the existing phrase) and
append a short example clause referencing the cross-tab sign-out behavior.
jacekradko
left a comment
There was a problem hiding this comment.
@bratsos I am wondering if other hooks like useUserBase for example have the same issue of returning stale initialState ?
f861ecc to
d81e40f
Compare
I completely changed the directory, this was indeed not the issue. Please check again! 🙏 |
Co-authored-by: Dylan Staley <88163+dstaley@users.noreply.github.com>
Ephem
left a comment
There was a problem hiding this comment.
This looks like a pragmatic fix, nice find! 🙏
| '@clerk/nextjs': patch | ||
| --- | ||
|
|
||
| Fix an App Router navigation edge case where duplicate in-flight redirects to the same destination could leave Clerk's awaitable navigation pending indefinitely. We now coalesce duplicate same-destination pushes into a single in-flight transition and reset pending destination state after flush. |
There was a problem hiding this comment.
NIT & subjective: Are the details of how we fixed it necessary here?
| Fix an App Router navigation edge case where duplicate in-flight redirects to the same destination could leave Clerk's awaitable navigation pending indefinitely. We now coalesce duplicate same-destination pushes into a single in-flight transition and reset pending destination state after flush. | |
| Fix an App Router navigation edge case where duplicate in-flight redirects to the same destination could leave Clerk's awaitable navigation pending indefinitely. |
Description
When a user signs out in one browser tab, other tabs viewing protected pages hang instead of redirecting to the sign-in page. The page remains stuck showing stale authentication data even though the session has been terminated.
Reproduction:
Root Cause
The issue was in
@clerk/nextjsApp Router awaitable navigation:RedirectToSignIncan trigger duplicate router.push calls to the same destination while the first transition is still in flight (commonly observed in dev/StrictMode-like remount/effect replay behavior).isPendingstuck and preventing promise buffer flush.Result: redirect flow appears hung even though auth state is already signed out.
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
Bug Fixes
Tests
Chores