npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kloudz-computing/retry-flow

v1.0.0

Published

Smart retry engine with job queue and DLQ support for Node.js

Readme

🔁 retry-flow

Smart Retry + Production-Grade Reliability System for Node.js

retry-flow is a TypeScript-first library designed to make your distributed systems more resilient. It provides a simple but powerful retry API, a policy-driven configuration system, and a core job queue with built-in Dead Letter Queue (DLQ) support.


🚀 Features

  • Smart Retries: Beyond simple loops. Supports Fixed, Exponential, and Linear backoff.
  • Jitter Support: Randomized delays to prevent thundering herd issues.
  • Policy-Driven: Reusable retry configurations for Different scenarios (e.g., http-safe).
  • Observability: Comprehensive lifecycle hooks for tracking attempts and failures.
  • Job Queue: Built-in memory queue with concurrency control and automated retries.
  • Dead Letter Queue (DLQ): Automatic capture and replay of permanently failed jobs.
  • TypeScript First: Rich types for a premium developer experience.

📦 Installation

npm install retry-flow

🛠️ Quick Start

Basic Retry

import { retry } from "retry-flow";

const result = await retry(
  async ({ attempt }) => {
    return await fetch("https://api.example.com/data");
  },
  {
    retries: 3,
    strategy: "exponential",
    baseDelay: 1000,
    jitter: true,
  }
);

Using Policies

import { retry } from "retry-flow";

// Uses the built-in 'http-safe' policy
const result = await retry(
  async () => fetch("..."),
  "http-safe"
);

🏗️ Core API

retry<T>(fn, options)

Executes an async function with the specified retry logic.

RetryOptions

| Option | Type | Default | Description | | :--- | :--- | :--- | :--- | | retries | number | 3 | Maximum number of retry attempts. | | strategy | "fixed" \| "exponential" \| "linear" | "fixed" | The wait strategy between attempts. | | baseDelay | number | 1000 | The initial delay in milliseconds. | | maxDelay | number | 30000 | The maximum delay allowed. | | jitter | boolean | false | Whether to add randomization to the delay. | | timeout | number | - | Timeout per attempt in milliseconds. | | retryIf | (error) => boolean | - | Predicate to decide if a retry should happen. | | abortIf | (error) => boolean | - | Predicate to immediately stop all retries. |

Hooks

{
  onRetry: ({ attempt, delay, error }) => console.log(`Retrying...`),
  onSuccess: ({ attempt, result }) => console.log(`Succeeded!`),
  onFailure: ({ error, attempts }) => console.log(`Failed after ${attempts} attempts.`),
}

📥 Job Queue & DLQ

retry-flow includes a lightweight job queue for background processing with built-in reliability.

import { createQueue } from "retry-flow";

const queue = createQueue({ driver: "memory", concurrency: 5 });

// Register a processor
queue.process("send-email", async (job) => {
  await mailer.send(job.data.to, job.data.subject);
});

// Add a job with custom retry policy
await queue.add("send-email", 
  { to: "[email protected]", subject: "Hello!" }, 
  { retryOptions: { retries: 5, strategy: "exponential" } }
);

Dead Letter Queue (DLQ)

When a job fails all retry attempts, it is moved to the DLQ.

const deadJobs = await queue.deadLetters.list();

// Replay a specific job
await queue.replay(deadJobs[0].id);

🔧 Advanced: Custom Policies

Register global policies to stay DRY across your codebase.

import { registerPolicy } from "retry-flow";

registerPolicy("my-custom-policy", {
  retries: 10,
  strategy: "linear",
  baseDelay: 500,
});

// Usage
await retry(fn, "my-custom-policy");

🧪 Development

# Run tests
npm test

# Run demo
npx tsx examples/demo.ts

📄 License

MIT © retry-flow