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

@nodii/saga

v0.14.0

Published

Saga orchestration library for the Nodii microservice stack — createSaga + step + stepParallel + cross-saga signals + sagaContext interceptor + SagaAdminService factory + @sagaCallable discipline tag + real PostgresSagaStateStore + RedisSignalBus + Patter

Readme

@nodii/saga

Placeholder package at v0.0.1. Implementation lands at v0.1.0 per the locked feature_doc.

Spec: https://planning.dev.nucleus-cloud.in/api/v1/feature-docs?serviceId=nodii-libs&docKey=saga

Retention: delete settled sagas after 90 days

Sagas that ended completed, compensated, compensated_manual or cancelled are hard-deleted 90 days after their last activity, with their saga_outbox rows. Every other status stays until something resolves it, as does a parent with a child row left and any saga with a kept ancestor. Each batch is cancelled after a time limit (default 60 s). Wire the job once at boot, on the owner pool (saga_state is owner-only):

import { makeSagaRetentionJob, runSagaRetentionLoop } from "@nodii/saga";

runSagaRetentionLoop(
  makeSagaRetentionJob({ sql: ownerSql, leaseRedis: redis, service: "billing" }),
);

It runs daily as a singleton under the lease nodii:lease:<service>:saga-retention, and Postgres checks the lease's fencing token inside every delete batch, so a replica that lost its lease cannot delete beside the one that took it over. A batch whose outcome is unknown keeps the lease until its transaction ends; the job learns that from the client, or by asking Postgres from another connection, and keeps the lease (warning about once a minute) while it cannot reach Postgres. Postgres keeps the highest token per lease key in saga_retention_fence. If the Redis fence counter is reset (FLUSHALL, a failover without persistence, a new Redis), every run then ends fence_lost and the job logs a warning with fence_counter_reset: true; to recover, run DELETE FROM saga_retention_fence WHERE scope = '<lease key>'. batchTimeoutMs (default 20 s) plus its client grace must be below the lease TTL (default 30 s). Defaults: retentionDays: 90, batchSize: 500 (one transaction per batch), maxBatchesPerRun: 1000, intervalMs: 86_400_000. If you have a scheduler, hand it job.name, job.intervalMs and job.handler instead of calling runSagaRetentionLoop. onRun gets the counts of each run, for your metric. The job writes no audit event.

Services that copy the saga SQL into their own migration runner (Flyway, golang-migrate, alembic): the retention DDL ships as a new file, ts/saga/src/migrations/002-saga-retention.sql, to run after 001-saga-state.sql. 001 is unchanged, so a runner that has already applied it is not affected. Without 002, every retention run ends store_error (saga_retention_fence_admit does not exist). applySagaMigrations (Python apply_saga_migrations, Go ApplySagaMigrations) runs both.

Only the saga_outbox table is purged. Known gap (RETENTION-FIX-81): the purge deletes only outbox rows that belong to a saga it deletes. Two kinds of saga_outbox row are never deleted: rows the participant worker writes under a remote orchestrator's saga id (no local saga row), and a deleted saga's rows written after the cutoff. Until RETENTION-FIX-81 lands, prune those yourself if they matter. There is no automatic orphan pass yet, because saga tables can share saga_outbox, and a check against one table would delete another table's live saga rows. A participant wired with a custom outboxTable keeps its rows there; prune that table yourself.

The saga migration gives saga_state its retention index and backfills its completed_at. A store on another table (tableName) needs the same: after applySagaMigrations, run sagaRetentionTableMigrationSql("<your table>") once (idempotent); it creates <table>_retention_idx and backfills that table. Saga ids must be unique across every saga table that shares saga_outbox: the purge deletes the outbox rows of each deleted saga by saga_id, whatever table wrote them.

The saga migration adds the partial index saga_state_retention_idx for this scan. A plain CREATE INDEX blocks writes to saga_state while it builds, so on a large table create it first with CREATE INDEX CONCURRENTLY IF NOT EXISTS saga_state_retention_idx ON saga_state (completed_at, id) WHERE status IN ('completed', 'compensated', 'compensated_manual', 'cancelled'); the migration then skips it. If that build fails, drop the invalid index it leaves and build it again.