MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / isTransientError

Function isTransientError

src/utils/retry.ts:98–115  ·  view source on GitHub ↗
(err: any)

Source from the content-addressed store, hash-verified

96
97/** Default transient classifier. */
98export function isTransientError(err: any): boolean {
99 if (err == null) return false;
100 // Never retry a user abort.
101 const msg = String(err?.message ?? err);
102 if (/\baborted\b/i.test(msg) && !/aborted by the server/i.test(msg)) return false;
103
104 const status = statusOf(err);
105 if (status !== undefined) {
106 // 408 Request Timeout, 409 Conflict (sometimes transient), 425 Too Early,
107 // 429 Too Many Requests, and all 5xx are worth retrying. 5xx EXCEPT 501.
108 if (status === 408 || status === 409 || status === 425 || status === 429) return true;
109 if (status >= 500 && status !== 501) return true;
110 return false; // other 4xx are permanent (400/401/403/404/422…)
111 }
112 // No status → look at the message/code for network-level signals.
113 const code = String(err?.code ?? '');
114 return TRANSIENT_CODE_RE.test(msg) || TRANSIENT_CODE_RE.test(code);
115}
116
117/**
118 * Run `fn`, retrying on transient failures with full-jitter exponential

Callers 2

Calls 1

statusOfFunction · 0.85

Tested by

no test coverage detected