Skip to content

Commit 5196122

Browse files
wobsorianobsingerftmclaudenikosdouvliscoderabbitai[bot]
authored
fix(clerk-js): Remove beforeunload event listener from SafeLock (#7775) (#7818)
Co-authored-by: Ben Singer <benjaminsinger@ftmedia.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Nikos Douvlis <nikosdouvlis@gmail.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 2e8d1bd commit 5196122

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
---
4+
5+
Removed redundant `beforeunload` event listener from SafeLock that was disabling the browser's back-forward cache (bfcache), degrading navigation performance.

packages/clerk-js/src/core/auth/safeLock.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ import Lock from 'browser-tabs-lock';
33
export function SafeLock(key: string) {
44
const lock = new Lock();
55

6-
// TODO: Figure out how to fix this linting error
7-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
8-
window.addEventListener('beforeunload', async () => {
9-
await lock.releaseLock(key);
10-
});
11-
126
const acquireLockAndRun = async (cb: () => Promise<unknown>) => {
137
if ('locks' in navigator && isSecureContext) {
148
const controller = new AbortController();

0 commit comments

Comments
 (0)