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

@zudojs/lifecycle

v1.0.0

Published

Application and component lifecycle orchestration with state machine, dependency ordering, graceful shutdown, rollback, and signals.

Readme

@zudojs/lifecycle

Application and component lifecycle orchestration with a state machine, dependency ordering, graceful shutdown, rollback, and signal handling.

Installation

npm install @zudojs/lifecycle

Quick Start

import { createLifecycleManager } from "@zudojs/lifecycle";

const manager = createLifecycleManager();

manager.register(database, { id: "db" });
manager.register(queue, { id: "queue", dependsOn: ["db"] });
manager.register(server, { id: "server", dependsOn: ["queue"] });

await manager.start();
// ... application running ...
await manager.shutdown();
manager.dispose();

Components are plain objects implementing any subset of the hooks:

const database = {
  name: "database",
  async initialize(context) {},
  async start(context) {},
  async ready(context) {},
  async stop(context) {},
  async dispose(context) {},
};

Startup and rollback

Phases run in order: initializestartready. Components with no dependency relationship run in parallel (bounded by concurrency).

If a critical component (the default) fails any startup phase, start() rolls the application back (stopdispose) and then rejects with a LifecycleStartError. Register a component with { critical: false } when its failure should not abort startup — the component is marked FAILED and startup continues.

Shutdown

shutdown() runs stopdispose in reverse dependency order. It is single-flight: concurrent callers, including the rollback triggered by a failing startup and the process signal handler, all await the same run.

shutdownTimeout (default 30s) is a real wall-clock deadline for the whole sequence. When it expires the lifecycle context's AbortSignal is aborted so hooks that observe it can unwind, and shutdown completes regardless. A component that ignores the signal is abandoned, not awaited forever.

Failing stop()/dispose() hooks are recorded: the component is marked FAILED, a component:failed event is emitted, and the result appears in getStatus().

Cancellation

Every hook receives a LifecycleContext whose signal is shared by the whole run and is aborted when the shutdown deadline expires. Long-running hooks should honour it:

async stop(context) {
  await drain({ signal: context.signal });
}

Events

manager.events.on(type, listener) subscribes to:

  • component:registered, component:initializing, component:initialized, component:starting, component:started, component:ready, component:stopping, component:stopped, component:failed
  • application:initializing, application:initialized, application:starting, application:ready, application:stopping, application:stopped, application:disposed

Listener exceptions are swallowed so observability never breaks the lifecycle.

Options

createLifecycleManager({
  concurrency: 10,        // parallel component operations per stage
  shutdownTimeout: 30_000, // global shutdown deadline (ms)
  handleSignals: true,     // install process signal handlers
  signals: ["SIGINT", "SIGTERM"], // defaults to DEFAULT_SHUTDOWN_SIGNALS
});

Per-component: id, dependsOn, priority, critical, timeout, retry: { attempts, delay, maxDelay, backoff }.

Use Cases

  • Coordinating service startup and shutdown
  • Managing component lifecycles
  • Handling process signals
  • Zero-downtime deployments