Package Comparison
Zero-dependency retry primitive · Any async fn · Node 18+ · Browser · Edge · Bun
| Feature | @ekaone/retry | fetch |
|---|---|---|
| Retry | ||
| Automatic retryRetries failed calls without manual loops | ✓ built-in | ✗ manual |
| Max attemptsHard cap on total tries including first call | ✓ maxAttempts | ✗ none |
| Exponential backoffDelay grows as baseDelay × 2^attempt | ✓ built-in | ✗ none |
| Linear backoffDelay grows linearly per attempt | ✓ built-in | ✗ none |
| Fixed backoffConstant delay between every attempt | ✓ built-in | ✗ none |
| JitterRandomised delay — prevents thundering herd | ✓ full jitter | ✗ none |
| Max delay capUpper bound on computed delay (maxDelayMs) | ✓ 30s default | ✗ none |
| Control | ||
| shouldRetry predicateSelective retry — only on recoverable errors | ✓ per-error | ✗ none |
| AbortSignal supportExternal cancellation mid-retry loop | ✓ loop-aware | ~ per-request only |
| Total timeoutCap on entire operation including delays | ✓ totalTimeoutMs | ✗ none |
| onError hookCallback fired after each failed attempt | ✓ per-attempt | ✗ none |
| Error Handling | ||
| RetryError with diagnosticsCarries attempts count, lastError, reason | ✓ RetryError | ✗ raw error |
| Failure reasonexhausted / aborted / timeout / rejected | ✓ reason field | ✗ none |
| Scope | ||
| Works with any async fnDB, SDK calls, agent turns, relay dispatch | ✓ any Promise | ✗ HTTP only |
| Anthropic / OpenAI / Gemini SDKWorks with all major LLM SDKs | ✓ yes | ✗ no |
| Works with native fetchCan wrap any fetch() call too | ✓ yes | ✓ yes |
| Runtime & Package | ||
| Zero dependencies | ✓ zero | ✓ native |
| Node / Browser / Edge / Bun / Deno | ✓ universal | ✓ universal |
| ESM + CJS dual output | ✓ tsup | N/A — native |
Retry
Automatic retry
Retries failed calls without manual loops
Max attempts
Hard cap on total tries
Exponential backoff
Delay grows as baseDelay × 2^attempt
Linear & Fixed backoff
Linear or constant delay strategies
Jitter
Randomised delay — prevents thundering herd
Max delay cap
Upper bound on computed delay
Control
shouldRetry predicate
Selective retry on recoverable errors only
AbortSignal support
External cancellation mid-retry loop
Total timeout
Cap on entire operation including delays
onError hook
Callback fired after each failed attempt
Error Handling
RetryError with diagnostics
Carries attempts, lastError, reason
Failure reason
exhausted / aborted / timeout / rejected
Scope
Works with any async fn
DB, SDK calls, agent turns, relay dispatch
Anthropic / OpenAI / Gemini
Works with all major LLM SDKs
Works with native fetch
Can wrap any fetch() call too
Runtime & Package
Zero dependencies
Node / Browser / Edge / Bun / Deno
ESM + CJS dual output