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

Function fetchWithRetry

src/services/remoteManagedSettings/index.ts:209–242  ·  view source on GitHub ↗

* Fetch remote settings with retry logic and exponential backoff * Uses existing codebase retry utilities for consistency

(
  cachedChecksum?: string,
)

Source from the content-addressed store, hash-verified

207 * Uses existing codebase retry utilities for consistency
208 */
209async function fetchWithRetry(
210 cachedChecksum?: string,
211): Promise<RemoteManagedSettingsFetchResult> {
212 let lastResult: RemoteManagedSettingsFetchResult | null = null
213
214 for (let attempt = 1; attempt <= DEFAULT_MAX_RETRIES + 1; attempt++) {
215 lastResult = await fetchRemoteManagedSettings(cachedChecksum)
216
217 // Return immediately on success
218 if (lastResult.success) {
219 return lastResult
220 }
221
222 // Don't retry if the error is not retryable (e.g., auth errors)
223 if (lastResult.skipRetry) {
224 return lastResult
225 }
226
227 // If we've exhausted retries, return the last error
228 if (attempt > DEFAULT_MAX_RETRIES) {
229 return lastResult
230 }
231
232 // Calculate delay and wait before next retry
233 const delayMs = getRetryDelay(attempt)
234 logForDebugging(
235 `Remote settings: Retry ${attempt}/${DEFAULT_MAX_RETRIES} after ${delayMs}ms`,
236 )
237 await sleep(delayMs)
238 }
239
240 // Should never reach here, but TypeScript needs it
241 return lastResult!
242}
243
244/**
245 * Fetch the full remote settings (single attempt, no retries)

Callers 1

Calls 4

getRetryDelayFunction · 0.85
logForDebuggingFunction · 0.85
sleepFunction · 0.50

Tested by

no test coverage detected