Skip to content

Commit 80d9830

Browse files
committed
handle callback errors
1 parent bf4a9a3 commit 80d9830

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { createWorkerTimers } from '@clerk/shared/workerTimers';
22

3+
import { debugLogger } from '@/utils/debug';
4+
35
const INTERVAL_IN_MS = 5 * 1_000;
46

57
/**
@@ -21,8 +23,13 @@ export class SessionCookiePoller {
2123

2224
const run = async () => {
2325
this.initiated = true;
24-
await cb();
25-
this.timerId = this.workerTimers.setTimeout(run, INTERVAL_IN_MS);
26+
try {
27+
await cb();
28+
} catch (error) {
29+
debugLogger.error('SessionCookiePoller callback failed', { error }, 'auth');
30+
} finally {
31+
this.timerId = this.workerTimers.setTimeout(run, INTERVAL_IN_MS);
32+
}
2633
};
2734

2835
void run();

0 commit comments

Comments
 (0)