Skip to content

Commit 7f47b36

Browse files
authored
fix(auth): include Cloudflare error codes in NETWORK_ERROR_CODES (#2239)
1 parent 433538b commit 7f47b36

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

packages/core/auth-js/src/lib/fetch.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ export type RequestMethodType = 'GET' | 'POST' | 'PUT' | 'DELETE'
3535
const _getErrorMessage = (err: any): string =>
3636
err.msg || err.message || err.error_description || err.error || JSON.stringify(err)
3737

38-
const NETWORK_ERROR_CODES = [502, 503, 504]
38+
// 502, 503, 504: Standard server/gateway errors
39+
// 520-524, 530: Cloudflare-specific error codes (web server down, connection timed out, etc.)
40+
// These are infrastructure errors and should not cause session invalidation.
41+
const NETWORK_ERROR_CODES = [502, 503, 504, 520, 521, 522, 523, 524, 530]
3942

4043
export async function handleError(error: unknown) {
4144
if (!looksLikeFetchResponse(error)) {

0 commit comments

Comments
 (0)