Remove beforeunload event listener from SafeLock#7775
Remove beforeunload event listener from SafeLock#7775bsingerftm wants to merge 2 commits intoclerk:mainfrom
Conversation
The beforeunload listener was redundant and degraded UX by disabling the browser's back-forward cache (bfcache). Lock cleanup is handled automatically: - Web Locks API releases locks natively on page unload - browser-tabs-lock has a built-in timeout mechanism that expires orphaned locks after ~5 seconds Fixes clerk#7714 https://claude.ai/code/session_01S2A4oTbEm3huTsR26xkU1E
|
|
@claude is attempting to deploy a commit to the Clerk Production Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughThe change removes the 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
Removes the beforeunload event listener from the SafeLock function. This listener was attempting to release locks when the page unloads, but it is both redundant and harmful to user experience.
Why this listener is harmful
The beforeunload event listener disables the browser's back-forward cache (bfcache), which degrades navigation performance. As noted in the codebase itself (beforeUnloadTracker.ts:6-7):
This is the root cause of the UX issues reported in #7714.
Why this listener is redundant
The SafeLock function uses a dual-locking strategy:
Trade-off analysis
In the fallback case, other tabs may need to wait up to 5 seconds to acquire an orphaned lock. This is acceptable because:
Additional benefit
This also removes a TypeScript linting issue (@typescript-eslint/no-misused-promises) where an async function was used as an event handler without proper promise handling.
🐛 Bug fix (fixes #7714)
Summary by CodeRabbit