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

@demystify/events

v0.3.0

Published

Fault-tolerant Postgres-native job/event pipeline: transactional outbox, idempotent consumers, retries with backoff+jitter, DLQ.

Downloads

443

Readme

@demystify/events

Durable jobs and events for TypeScript — Postgres-backed (pgmq) with a transactional outbox, idempotent consumers, exponential backoff + full jitter retries, and a dead-letter queue. Ships a full-fidelity in-memory driver and an optional PGlite subpath so the same code runs offline with no database.

Part of the Demystify Core Services suite. A matching Python package, demystify-events, mirrors this API.

Install

npm add @demystify/events
# or: pnpm add @demystify/events

Quickstart (offline, no database)

import { createEventsClient } from "@demystify/events";
import { MemoryQueueDriver } from "@demystify/events"; // in-memory, full semantics

const client = createEventsClient({ driver: new MemoryQueueDriver() });

await client.enqueue("email.send", { to: "[email protected]" });

// idempotent, retried with backoff+jitter, DLQ on poison
await client.work("email.send", async (ctx, job) => {
  // effects committed in the same transaction as the ack
});

For real Postgres, use the PgmqQueueDriver + PgExecutor adapters with a connection pool. For SQL-real tests without a server, import the ./pglite subpath.

Postgres requirements

PgmqQueueDriver runs on the pgmq Postgres extension. It must be installed in the target database before the driver is used:

CREATE EXTENSION pgmq;

Stock postgres images do not ship pgmq — use an image that does:

  • ghcr.io/demystify-systems/postgres-pgvector-pgmq — ours; pgvector + pgmq combined
  • quay.io/tembo/pg16-pgmq — Tembo's Postgres 16 + pgmq image

If the extension is missing, the driver fails fast with an actionable error instead of the cryptic relation "pgmq.q_x" does not exist:

pgmq extension not available in this database. Run CREATE EXTENSION pgmq;
(requires a Postgres image that ships pgmq — e.g.
ghcr.io/demystify-systems/postgres-pgvector-pgmq or quay.io/tembo/pg16-pgmq).
See the @demystify/events README, 'Postgres requirements'.

The original Postgres error is preserved as the thrown error's cause.

Choosing a driver

| Driver | Durability | Intended use | | -------------------------------------------- | ---------------------------------------------- | ---------------------------------- | | MemoryQueueDriver / EphemeralQueueDriver | None — process memory, jobs lost on restart | Tests, demos | | PgmqQueueDriver | Durable — Postgres (pgmq extension) | Production | | ./pglite subpath | Durable within a file/dir (embedded Postgres) | Local/offline SQL-real tests |

EphemeralQueueDriver is the preferred, self-describing alias for MemoryQueueDriver — the same class, named so nobody ships process memory as durable delivery by accident.

To keep the footgun visible, constructing the in-memory driver logs a console.warn once per process:

[@demystify/events] MemoryQueueDriver is EPHEMERAL (jobs lost on restart) — fine for
tests/demos, not for durable delivery. Use PgmqQueueDriver in production, or set
DMSTFY_EVENTS_ALLOW_EPHEMERAL=1 to silence.

The warning is suppressed automatically under test runs (NODE_ENV=test or vitest's VITEST env marker). If you run the in-memory driver on purpose outside tests (demos, kiosks, scratch tooling), set DMSTFY_EVENTS_ALLOW_EPHEMERAL=1 to silence it.

Exports

  • createEventsClient / EventsClient — enqueue, transactional enqueue, workers, relay
  • contractBackoff, fullJitterBackoff, DEFAULT_BACKOFF — retry schedules
  • RelayWorker — transactional outbox relay (SKIP LOCKED)
  • validateSchema — JSON-schema event-contract validation
  • Ports: QueueDriver, Sql, Tx, SqlExecutor
  • Adapters: MemoryQueueDriver (alias EphemeralQueueDriver), PgmqQueueDriver, PgExecutor (+ ./pglite)
  • VERSION — the published package version string

See the module README for the delivery guarantees, chaos-test results, and the /ops/v1 API.

License

MIT © Demystify Systems