Retries: #Predictable

Execute async functions with fixed delays or exponential backoff — with absolutely no magic, no dependencies

Terminal

npm install --save execute-with-retries

Execute-with-retries is designed for developers who want retry logic they can understand, trust, and tune. Clear boundaries. Predictable outcomes.

Explicit by design.
Predictable by default.

./src/feature/home-page/service/index.ts

/* node modules */
import { executeWithRetries } from "execute-with-retries";

/* module */
async function getRandomQuote(): Promise<Record<string, any>> {
  const API_URL = "https://dummyjson.com/quotes/random";
  const response = await fetch(API_URL);
  if (!response.ok) {
    throw new Error("Request Failed");
  } else {
    return await response.json();
  }
}

/* call */
const randQuote = await executeWithRetries(getRandomQuote, {retries: 5});
console.log(randQuote);
/* Shown as an example, if the request fails due to a transient error, the operation is retried according to the
configured retry policy before ultimately rejecting. */
      
  • Zero Dependencies

    Zero Dependencies

    Ships as a single, dependency-free utility with no external runtime requirements or transitive packages to audit or maintain.

  • No Side Effects

    No Side Effects

    Performs no logging, telemetry, or global mutation by default — behavior is fully controlled by the caller.

  • Functional by Design

    Functional by Design

    Exposed as pure async functions, not classes, keeping usage simple, composable, and easy to reason about.

  • Universal Runtime Support

    Universal Runtime Support

    Works consistently in both client-side and server-side JavaScript environments without environment-specific configuration.

  • Minimal, Intentional API

    Minimal, Intentional API

    Provides sensible defaults with a tiny configuration surface, making retry behavior explicit without unnecessary options.

  • Async-Only Semantics

    Async-Only Semantics

    Designed exclusively for async functions that return promises, enforcing clarity at the async boundary.