Skip to content

Commit 3438d17

Browse files
authored
fix(clerk-js): Re-throw network errors in FraudProtection (#7254)
1 parent 5e5e24a commit 3438d17

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
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+
Fix issue where network errors were being masked by fraud protection logic, preventing cache fallback from triggering properly.

packages/clerk-js/src/core/fraudProtection.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ClerkRuntimeError, isClerkAPIResponseError } from '@clerk/shared/error';
1+
import { ClerkRuntimeError, isClerkAPIResponseError, isClerkRuntimeError } from '@clerk/shared/error';
22

33
import { CaptchaChallenge } from '../utils/captcha/CaptchaChallenge';
44
import type { Clerk } from './resources/internal';
@@ -45,6 +45,12 @@ export class FraudProtection {
4545
throw e;
4646
}
4747

48+
// Network errors should bypass captcha logic and be re-thrown immediately
49+
// so cache fallback can be triggered
50+
if (isClerkRuntimeError(e) && e.code === 'network_error') {
51+
throw e;
52+
}
53+
4854
if (e.errors[0]?.code !== 'requires_captcha') {
4955
throw e;
5056
}

0 commit comments

Comments
 (0)