Retry

_archivesourcetypescript
Path: _archive/loom-stale-pre-sprint-snapshot/src/lib/retry.tsRelative: loom-stale-pre-sprint-snapshot/src/lib/retry.tsSubproject: _archiveCategory: archived
Lines: 45Bytes: 1,583Imports: 1Exports: 2

Content Preview

  1. import { RetryExhaustedError } from "../types/errors";
  2. /**
  3. * Exponential backoff with FULL jitter (HC-6): delay = rand(0, min(cap, base·2^n)).
  4. * Minimum 3 attempts on anything that touches a network.
  5. */
  6. export interface RetryOptions {
  7. attempts?: number; // >= 3 enforced
  8. baseMs?: number;
  9. capMs?: number;
  10. /** Return false to short-circuit on non-retryable errors (e.g. 4xx). */
  11. retryable?: (e: unknown) => boolean;
  12. /** Injected for tests; defaults to real sleep. */
  13. sleep?: (ms: numb