pg-workflows v0.13.0 is a TypeScript workflow engine that uses PostgreSQL as its sole backing store for durable execution, event-driven orchestration, and automatic retries. It eliminates the need for Redis, message brokers, or external workflow servers by storing all state in Postgres. Released under MIT, it targets Node >=18.0.0 and Postgres >=10. Key differentiators include a minimal API that feels like plain async TypeScript (no DSL), built-in step-level persistence with exactly-once semantics, event-driven pauses (step.waitFor), scheduling primitives (delay, waitUntil), and client/worker separation. Compared to Temporal or BullMQ, it requires zero new infrastructure and automatically runs schema migrations on start. Peer dependencies are pg (Postgres client) and optionally @opentelemetry/api for tracing. The package ships TypeScript types and is ESM-only.
npm install pg-workflowsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Defines a simple two-step workflow, initializes the engine with a Postgres connection, starts it, triggers a run, and then stops cleanly.
Ensure your project uses ESM (type: 'module' in package.json or .mjs extension). Switch from require() to import statements.
Set the 'disableMigrations' option to true in the WorkflowEngine config and run migrations separately (if supported) or review the migration SQL.
Replace 'schema' with 'pgSchema' in the engine configuration object.
Wrap all async logic inside step.run() calls. The workflow callback itself should not be async (but step.run accepts async functions).
Ensure you emit the event with the exact same eventName string. Use constants to avoid typos.
Run 'npm install pg-workflows pg' and ensure your Node.js version >=18.
Change to 'import { WorkflowEngine } from 'pg-workflows'' and ensure your project is configured for ESM.Ensure the database user has CREATE privileges, or set 'disableMigrations: true' and run migrations manually if you have a management process.
Check the input object against the schema. Use a type-safe input or add validation before calling startWorkflow.
Ensure the event is emitted within the timeout window. Check event name spelling and that engine.emitEvent is called correctly.