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

@resili/undici

v0.1.0-alpha.1

Published

Undici-compatible adapter for Resili.

Downloads

24

Readme

@resili/undici

Minimal Undici-compatible request adapter for Resili.

@resili/undici wraps an Undici-compatible request function with @resili/core. It returns a single resilient request(options) function that preserves the structural request and response shape implemented by this package.

This package does not depend on Undici directly. Provide an implementation that matches the exported UndiciImplementation type.

For the full framework overview, see the repository README.

Installation

pnpm add @resili/core @resili/undici
npm install @resili/core @resili/undici
yarn add @resili/core @resili/undici

Node.js 20 or newer is required.

Quick Start

import { createUndici, type UndiciImplementation } from "@resili/undici";

const requestImplementation: UndiciImplementation = async (options) => ({
  statusCode: 200,
  headers: {},
  body: `requested ${options.path}`,
});

const request = createUndici({
  request: requestImplementation,
  timeout: { perAttemptMs: 1_000 },
  retry: { maxAttempts: 3, jitter: "none" },
});

const response = await request({
  origin: "https://api.example.com",
  path: "/users",
  method: "GET",
});

createUndici()

import { createUndici, type UndiciImplementation } from "@resili/undici";

const requestImplementation: UndiciImplementation = async (options) => {
  return {
    statusCode: 204,
    headers: {},
    body: `ok:${options.path}`,
  };
};

const request = createUndici({
  request: requestImplementation,
  circuitBreaker: { minimumThroughput: 10 },
});

Supported core config fields:

| Field | Purpose | | ---------------- | ------------------------------------------- | | retry | Retry failed calls. | | timeout | Apply per-attempt timeout behavior. | | circuitBreaker | Stop calls while a dependency is unhealthy. | | bulkhead | Bound concurrency and queue depth. | | rateLimiter | Limit request rate in memory. | | fallback | Return an alternate Undici response. | | classifier | Override failure classification. | | store | Override the state store service. | | clock | Override timers and time source. | | policies | Register custom policy factories. |

The request option is adapter-specific and is removed before configuration is passed to @resili/core.

Basic Request Example

import { createUndici, type UndiciImplementation } from "@resili/undici";

const requestImplementation: UndiciImplementation = async (options) => ({
  statusCode: 200,
  headers: { "content-type": "application/json" },
  body: JSON.stringify({ path: options.path }),
});

const request = createUndici({ request: requestImplementation });

const response = await request({
  origin: "https://api.example.com",
  path: "/health",
  method: "GET",
});

The adapter shallow-copies request options and sets options.signal to the Resili context signal for the active execution. Resili's signal overrides a caller-provided signal.

Retry Example

import { createUndici, type UndiciImplementation } from "@resili/undici";

const requestImplementation: UndiciImplementation = async (options) => ({
  statusCode: 200,
  headers: {},
  body: `requested ${options.origin}${options.path}`,
});

const request = createUndici({
  request: requestImplementation,
  retry: {
    maxAttempts: 3,
    backoff: "exponential",
    baseDelayMs: 100,
    maxDelayMs: 1_000,
    jitter: "none",
  },
});

const response = await request({
  origin: "https://api.example.com",
  path: "/orders",
  method: "GET",
});

Retry behavior is delegated to @resili/core.

Timeout Example

import { createUndici, type UndiciImplementation } from "@resili/undici";

const requestImplementation: UndiciImplementation = async (options) => ({
  statusCode: 200,
  headers: {},
  body: options.signal?.aborted ? "aborted" : "ok",
});

const request = createUndici({
  request: requestImplementation,
  timeout: { perAttemptMs: 750 },
});

Timeout passes the Resili context signal into the injected request implementation.

Fallback Example

import { createUndici, type UndiciImplementation } from "@resili/undici";

const requestImplementation: UndiciImplementation = async () => {
  throw new Error("downstream unavailable");
};

const request = createUndici({
  request: requestImplementation,
  fallback: {
    handler() {
      return { statusCode: 200, headers: {}, body: "fallback" };
    },
  },
});

const response = await request({
  origin: "https://api.example.com",
  path: "/status",
});

Fallback handlers may return an UndiciResponse or a promise for one.

Current Limitations

  • No real Undici runtime dependency is included.
  • No Agent support.
  • No Pool support.
  • No Dispatcher helpers.
  • No MockAgent or ProxyAgent helpers.
  • No WebSocket support.
  • No streaming helpers.
  • No HTTP status classification.
  • No response body handling beyond returning the injected implementation result.
  • No OpenTelemetry or metrics exporters.

The adapter is intentionally thin. Use @resili/core policies or custom policies for behavior beyond request wrapping.

Documentation

License

MIT © Resili contributors.