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

retry-cluck

v0.0.4

Published

retry utility for NestJS with support for customizable backoff, jitter, and future-proof features like HTTP and gRPC retries.

Downloads

10

Readme

retry-cluck

A flexible and NestJS-ready utility for implementing retry patterns with support for advanced features like idempotency and diverse protocols (HTTP, gRPC, etc.).


Features

  • Retry Strategies: Supports exponential backoff, customizable delays, and jitter to handle transient failures.
  • Protocol Agnostic: Designed to support HTTP, gRPC, and other protocols.
  • Idempotency Handling: Future support for safely retrying stateful operations.
  • Configurable: Fine-tune retries, delays, and backoff strategies to fit your needs.

Installation

npm install retry-cluck

Usage

First, import the RetryCluckModule in your NestJS module:

import { Module } from '@nestjs/common';
import { RetryCluckModule } from 'retry-cluck';

@Module({
  imports: [
    RetryCluckModule.forRoot({
      // Global default options can be set here
      retries: 3,
      delayMs: 1000,
    }),
  ],
})
export class AppModule {}

Then, you can use the RetryCluckService in your services:

import { Injectable } from '@nestjs/common';
import { RetryCluckService } from 'retry-cluck';

@Injectable()
export class ExampleService {
  constructor(private readonly retryCluck: RetryCluckService) {}

  async performOperation() {
    const result = await this.retryCluck.retry(async () => someUnreliableOperation(), {
      retries: 5, // Max retries for this operation
      delayMs: 2000, // Initial delay in ms
      backoffFactor: 2, // Backoff factor for exponential delay increase
      shouldUseRandomJitter: true, // Whether to apply random jitter to the delay
      jitterFactor: 0.5, // Factor used to calculate the random jitter
    });

    console.log('Result:', result);
  }
}

Options

The retry method accepts an options parameter of type Partial<RetryOptions>, where RetryOptions is defined as:

interface RetryOptions {
  retries: number; // Maximum number of retry attempts
  delayMs: number; // Initial delay in milliseconds
  backoffFactor: number; // Factor to increase the delay after each failure
  shouldUseRandomJitter: boolean; // Flag to enable/disable random jitter
  jitterFactor: number; // Factor to adjust the amount of jitter applied
}

Option Priority

The retry method allows you to customize retry behavior with the following options:

  • Service Options: If options are passed when calling retry, these will take priority over the global module options.
  • Global Module Options: If no service-specific options are provided, the options configured in the RetryCluckModule will be used.
  • Default Options: If neither service nor global options are provided, the method will fall back to default values: 3 retries, 1000 ms delay, and other preset configurations.

Future Vision

  • Protocol-Specific Modules: Built-in retry mechanisms for HTTP, gRPC, and database queries.
  • Idempotency Enforcement: Tools to ensure safe retries for stateful operations.
  • Custom Hooks: Pre- and post-retry hooks for advanced workflows.

Open to Contribute

Contributions are welcome! If you have suggestions for improvements or new features, please feel free to open an issue or submit a pull request.

How to Contribute

  1. Fork the repository.
  2. Create your feature branch (git checkout -b feature/new-feature).
  3. Commit your changes (git commit -m 'feat: add some feature').
  4. Push to the branch (git push origin feature/new-feature).
  5. Open a pull request.

Development

Run Tests

npm run test

Build the Package

npm run build

License

MIT