Skip to content
Merged
5 changes: 5 additions & 0 deletions .changeset/remove-beforeunload-safelock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---

Removed redundant `beforeunload` event listener from SafeLock that was disabling the browser's back-forward cache (bfcache), degrading navigation performance.
6 changes: 0 additions & 6 deletions packages/clerk-js/src/core/auth/safeLock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ import Lock from 'browser-tabs-lock';
export function SafeLock(key: string) {
const lock = new Lock();

// TODO: Figure out how to fix this linting error
// eslint-disable-next-line @typescript-eslint/no-misused-promises
window.addEventListener('beforeunload', async () => {
await lock.releaseLock(key);
});

const acquireLockAndRun = async (cb: () => Promise<unknown>) => {
if ('locks' in navigator && isSecureContext) {
const controller = new AbortController();
Expand Down