MCPcopy Index your code
hub / github.com/codeaashu/claude-code / fetchWithRetry

Function fetchWithRetry

src/services/policyLimits/index.ts:267–295  ·  view source on GitHub ↗

* Fetch policy limits with retry logic and exponential backoff

(
  cachedChecksum?: string,
)

Source from the content-addressed store, hash-verified

265 * Fetch policy limits with retry logic and exponential backoff
266 */
267async function fetchWithRetry(
268 cachedChecksum?: string,
269): Promise<PolicyLimitsFetchResult> {
270 let lastResult: PolicyLimitsFetchResult | null = null
271
272 for (let attempt = 1; attempt <= DEFAULT_MAX_RETRIES + 1; attempt++) {
273 lastResult = await fetchPolicyLimits(cachedChecksum)
274
275 if (lastResult.success) {
276 return lastResult
277 }
278
279 if (lastResult.skipRetry) {
280 return lastResult
281 }
282
283 if (attempt > DEFAULT_MAX_RETRIES) {
284 return lastResult
285 }
286
287 const delayMs = getRetryDelay(attempt)
288 logForDebugging(
289 `Policy limits: Retry ${attempt}/${DEFAULT_MAX_RETRIES} after ${delayMs}ms`,
290 )
291 await sleep(delayMs)
292 }
293
294 return lastResult!
295}
296
297/**
298 * Fetch policy limits (single attempt, no retries)

Callers 1

fetchAndLoadPolicyLimitsFunction · 0.70

Calls 4

fetchPolicyLimitsFunction · 0.85
getRetryDelayFunction · 0.85
logForDebuggingFunction · 0.85
sleepFunction · 0.50

Tested by

no test coverage detected