MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / calculateBackoffDelay

Function calculateBackoffDelay

cli/src/utils/codebuff-api.ts:232–240  ·  view source on GitHub ↗
(
  attempt: number,
  initialDelayMs: number,
  maxDelayMs: number,
)

Source from the content-addressed store, hash-verified

230 * Calculate delay with exponential backoff and jitter
231 */
232const calculateBackoffDelay = (
233 attempt: number,
234 initialDelayMs: number,
235 maxDelayMs: number,
236): number => {
237 const exponentialDelay = initialDelayMs * Math.pow(2, attempt)
238 const jitter = Math.random() * 0.3 * exponentialDelay // 0-30% jitter
239 return Math.min(exponentialDelay + jitter, maxDelayMs)
240}
241
242/**
243 * Check if an error is retryable (network errors).

Callers 1

requestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected