Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-network-error-cache-fallback.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---

Fix issue where network errors were being masked by fraud protection logic, preventing cache fallback from triggering properly.
8 changes: 7 additions & 1 deletion packages/clerk-js/src/core/fraudProtection.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ClerkRuntimeError, isClerkAPIResponseError } from '@clerk/shared/error';
import { ClerkRuntimeError, isClerkAPIResponseError, isClerkRuntimeError } from '@clerk/shared/error';

import { CaptchaChallenge } from '../utils/captcha/CaptchaChallenge';
import type { Clerk } from './resources/internal';
Expand Down Expand Up @@ -45,6 +45,12 @@ export class FraudProtection {
throw e;
}

// Network errors should bypass captcha logic and be re-thrown immediately
// so cache fallback can be triggered
if (isClerkRuntimeError(e) && e.code === 'network_error') {
throw e;
}

if (e.errors[0]?.code !== 'requires_captcha') {
throw e;
}
Expand Down
Loading