# bunqueue v2.9.24

bunqueue v2.9.24: live bunqueue top TUI, PostgreSQL 16-19 multi-pod Workflow Engine, Schema v2, 6-86 block PG journal replay, lease fencing, and Bun 1.4.5.

Canonical: https://bunqueue.dev/blog/bunqueue-v2-9-24/

---

A zero-dependency live terminal dashboard (`bunqueue top`), PostgreSQL 16-19 multi-pod storage and production hardening for the Workflow Engine, PostgreSQL 19 support, fast cursor-bounded journal replay (6-86 shared blocks in 0.01-0.05 ms), deeper lease and flow hardening, and Bun 1.4.5.

![](https://github.com/egeominotti.png?size=64) [egeominotti](https://github.com/egeominotti)

**bunqueue v2.9.24** brings two headline capabilities for production operators alongside deep engine hardening across SQLite and PostgreSQL. First, `bunqueue top` puts a `k9s`/`btop`-inspired terminal dashboard directly in the CLI with zero new runtime dependencies and no wire-protocol changes. Second, `bunqueue/workflow` gains native PostgreSQL 16-19 multi-pod storage (`EngineOptions.postgres`), Schema v2 with O(active) partial indexes, idempotent starts, durable timers, cooperative `AbortSignal` cancellation, lease-loss watchdogs, rolling-deploy support, and MCP PostgreSQL integration.

This release also adds PostgreSQL 19 (`19.0`) across CI, Docker Compose examples, and SDK conformance, upgrades the runtime pin from Bun `1.4.4` to `1.4.5`, drops PostgreSQL event journal replay scans from **449 shared blocks** down to **6-86 shared blocks in 0.01-0.05 ms** ([#199](https://github.com/egeominotti/bunqueue/issues/199)), and closes lease-fencing, SQLite durability, flow-dependency, multi-broker PostgreSQL, and saga-recovery edge cases. Every observable change and migration note is listed in [Before you upgrade](#before-you-upgrade).

#### To install bunqueue v2.9.24

```bash title="standalone binary (macOS & Linux)"
curl -fsSL https://bunqueue.dev/install.sh | sh -s -- --version 2.9.24
```

```powershell title="standalone binary (Windows)"
& ([scriptblock]::Create((irm https://bunqueue.dev/install.ps1))) -Version 2.9.24
```

```bash title="bun"
bun add bunqueue@2.9.24
```

```bash title="npm"
npm install bunqueue@2.9.24
```

```bash title="docker"
TAG=2.9.24
docker run -p 6789:6789 -p 6790:6790 ghcr.io/egeominotti/bunqueue:$TAG
```

#### To upgrade bunqueue

```bash
bun add bunqueue@latest
```

## Monitor and triage queues from your shell with `bunqueue top`

`bunqueue top` is a zero-dependency live terminal UI (`src/cli/top/`) that attaches to any bunqueue broker over a single persistent TCP+TLS+Auth connection using existing wire commands (`Auth`, `Hello`, `DashboardOverview`, `DashboardQueues`, `DashboardQueue`, `GetQueueLimits`, `GetJob`, `GetLogs`, `GetDlqStats`, `Dlq`, `ListWebhooks`, `Pause`, `Resume`, `RateLimit`, `RateLimitClear`, `SetConcurrency`, `ClearConcurrency`, `PUSH`, `Drain`, `Cancel`, `Promote`, `Discard`, `RetryDlq`, `PurgeDlq`, `SetWebhookEnabled`, `RemoveWebhook`, `CronDelete`, and `CompactMemory`). No broker hot paths or protocol frames were changed.

```bash
# Try the built-in interactive simulator with no running server
bunx bunqueue top --demo

# Attach to a live broker
bunx bunqueue top --host 127.0.0.1 --port 6789 --theme cyber

# Scriptable single-frame and JSON snapshots
bunx bunqueue top --once --view dlq -q billing
bunx bunqueue top --once --json
```

What ships inside `bunqueue top`:

- **Live telemetry and 4 themes:** A 4-row truecolor Braille throughput area chart, `p50`/`p95`/`p99` latency percentiles, a heap/RSS gauge, and 4 live color themes (`cyber`, `tokyo`, `amber`, `mono`).
- **7 interactive views and drill-down:** Switch across Queues (with live deltas and heat load bars), Workers, Crons, DLQ Triage (deterministic root-cause clustering with inline secret and ANSI scrubbing), Webhooks, a live Activity feed derived from snapshot diffs, and **`[7] Workflows`** (zero-DDL SQLite `--workflow-db` or PostgreSQL 16-19 `--workflow-pg` inspection, step-by-step timeline drill-down, and live transactional `waitFor` signal delivery via `s` and `:wf`), plus a toggleable bottom split preview (`v`) and Queue -> Job + Logs inspection.
- **Live operator controls and command palette:** Pause or resume queues, tune rate limits and concurrency, quick-push jobs, promote/discard/cancel jobs, run canary or full DLQ retries, purge DLQs, manage webhooks and crons, wake parked workflows, and compact broker memory with `y/N` confirmation on destructive actions and a `k9s`-style `:` command palette.
- **Interactive browser simulator:** The same `--demo` engine runs live on the documentation homepage with six guided scenario presets (including `[7] Workflows & Signals`), in the [Terminal UI guide](https://bunqueue.dev/guide/top/), and in the [dedicated `bunqueue top` launch post](https://bunqueue.dev/blog/bunqueue-top/).

## Verified installers, package manifests, and `bunqueue doctor --deep`

Release v2.9.24 ships production-grade single-binary installers at `https://bunqueue.dev/install.sh` (strictly POSIX `sh`) and `https://bunqueue.dev/install.ps1` (PowerShell 5.1+ and 7+) alongside deterministic package manager manifests and deep host diagnostics:

```bash
# macOS (arm64/x64 + Rosetta 2 detection) and Linux (glibc or musl/Alpine)
curl -fsSL https://bunqueue.dev/install.sh | sh

# Hardened Linux systemd server with generated AUTH_TOKENS and live healthcheck
curl -fsSL https://bunqueue.dev/install.sh | sudo sh -s -- --systemd

# Deep production audit: TCP/TLS+Auth+Ping, SQLite WAL & integrity, PostgreSQL 16+, systemd
bunqueue doctor --deep --host 127.0.0.1 --port 6789 --token "$BQ_TOKEN"
```

- **Fail-closed installers:** Both `install.sh` and `install.ps1` enforce HTTPS with TLS 1.2, mandatory `SHA256SUMS` verification, tar-slip and zip-slip path guards, a pre-swap `--version` smoke check with automatic rollback, optional GitHub Sigstore provenance verification (`--verify-attestation`), `--dry-run`, and `--uninstall`. On Linux, `--systemd` provisions a dedicated `bunqueue` user, `/var/lib/bunqueue` (`0750`), `/etc/bunqueue/bunqueue.env` (`0640`, preserving existing `AUTH_TOKENS` on upgrades), and a hardened `bunqueue.service` unit (`ProtectSystem=strict`, `NoNewPrivileges=true`).
- **Homebrew, Scoop, and Winget manifests:** `scripts/generate-package-manifests.ts` builds checksum-verified `homebrew/bunqueue.rb` (macOS and Linux with a `service` block), `scoop/bunqueue.json` (Windows `64bit` and `arm64`), and Winget v1.9.0 manifests from `SHA256SUMS`. Every GitHub Release attaches `bunqueue.rb` and `bunqueue.json`, and CI includes a non-blocking `publish-homebrew-tap` job for `egeominotti/homebrew-tap` when `HOMEBREW_TAP_TOKEN` is set.
- **Deep production diagnostics (`bunqueue doctor`):** Keeps default `bunqueue doctor` HTTP `/health` behavior intact while adding opt-in `--deep`, `--tcp`, `--sqlite <path>` (read-only WAL, `quick_check`, and disk headroom), `--pg <url>` (bounded PostgreSQL 16+ and schema/index probe with credentials stripped), `--systemd` (service state, `bunqueue.env` permission audit, `/var/lib/bunqueue` writability), `--http-port <port>`, dedicated `bunqueue doctor --help`, and structured `--json` output.

## Run `bunqueue/workflow` across multiple pods on PostgreSQL 16-19

Previously, `bunqueue/workflow` stored execution state in local SQLite (`dataPath`). In v2.9.24 ([#196](https://github.com/egeominotti/bunqueue/issues/196)), `EngineOptions.postgres` adds native `Bun.SQL` persistence for PostgreSQL 16-19 so multiple Kubernetes pods can share one PostgreSQL workflow namespace (`bunqueue_workflow_executions`, `bunqueue_workflow_executions_archive`, `bunqueue_workflow_schema_migrations`) and a remote TCP bunqueue step queue with zero local SQLite files.

```typescript
import { Engine } from 'bunqueue/workflow';

const engine = new Engine({
  postgres: {
    url: process.env.DATABASE_URL!,
    namespace: 'orders',
  },
  connection: { host: 'bunqueue.internal', port: 6789 },
  autoStart: false,
});

engine.register(orderWorkflow);
await engine.ready();
```

Alongside PostgreSQL storage, v2.9.24 hardens the Workflow Engine across both SQLite and PostgreSQL:

- **Schema v2 and O(active) partial indexes:** Automatic startup migration (advisory-locked with transactional backfill on PostgreSQL) adds `needs_rollback`, `idempotency_key`, and `definition_hash` plus O(active) partial indexes (`idx_wf_recoverable` / `idx_wf_pg_recoverable`, `idx_wf_active_by_name` / `idx_wf_pg_active_by_name`, and unique `idx_wf_idempotency_key` / `idx_wf_pg_idempotency_key`) so recovery and registration checks scan only live or rollback-owed runs instead of settled history.
- **Idempotency, deadlines, and completion waiting:** `engine.start(name, input?, { idempotencyKey?, executionId?, timeoutMs? })` provides atomic deduplication (`RunHandle.deduplicated`) and durable execution deadlines (`deadlineAt`), paired with `engine.waitForCompletion(id, { timeoutMs?, pollIntervalMs? })` across forward runs and saga compensations.
- **Cancellation, lease-loss watchdogs, and retry controls:** `engine.cancel(id, { reason?, compensate? })` transitions runs to `'cancelled'` and emits `'workflow:cancelled'` (16 workflow events total), propagating `AbortSignal` (`ctx.signal`) through steps, parallel blocks, branches, loops, `forEach`, `map`, sub-workflows, and compensations. An independent local deadline watchdog (`startLeaseRenewalWithWatchdog` in `src/client/workflow/postgresLeaseWait.ts`) self-fences a partitioned pod under silent TCP blackholes (`iptables -j DROP`) before a surviving replica can take over. Also adds `NonRetryableError`, `StepOptions.backoff`, `StepOptions.retryIf`, `WorkflowLeaseLostError`, and `WorkflowDefinitionMismatchError`.
- **Durable timers:** `Workflow.sleep(name, durationMs)` and `Workflow.sleepUntil(name, target)` park executions in `state='waiting'` with an indexed `wait_deadline_at`, freeing Worker concurrency slots and PostgreSQL leases and resuming after restarts or pod evictions.
- **Rolling deploys, sweepers, health, and MCP PostgreSQL:** Adds `EngineOptions.autoStart`, `engine.register(wf, { legacy: true })` for zero-downtime multi-version rollouts, `PostgresRecoverySweeper` (`recoverySweepIntervalMs`, `orphanGraceMs`), `EngineOptions.retention`, `engine.getHealth()`, `engine.getStats()` / `engine.getStatsAsync()`, and fail-closed zero-DDL PostgreSQL support for opt-in MCP workflow tools via `BUNQUEUE_MCP_WORKFLOW_POSTGRES_URL` and `BUNQUEUE_MCP_WORKFLOW_POSTGRES_NAMESPACE`.
- **Rewritten Workflow documentation:** All 7 Workflow Engine guides (`Overview`, `Quick Start`, `Steps & Control Flow`, `Rollback (Saga)`, `Durability & Idempotency`, `Human Approval`, and `API Reference`) were rewritten with interactive 3D isometric diagrams and a homepage showcase.

## PostgreSQL 19 (`19.0`), Bun `1.4.5`, and cursor-bounded journal replay

- **PostgreSQL 19 (`19.0`) matrix:** Added `postgres:19.0-alpine` and native Debian 13 `postgresql-19` across the CI PostgreSQL matrix (`19.0`, `18.6`, `17.x`, `16.x`), SDK conformance sandbox, Docker Compose examples, test harness defaults, and docs.
- **Event journal replay seeks directly into the index ([#199](https://github.com/egeominotti/bunqueue/issues/199)):** Adding `AND journal.commit_seq >= ${cursor.commitSeq}` alongside the tuple predicate in `loadPostgresJournalEventsAfter` lets PostgreSQL 16-19 seek directly into `bunqueue_event_commits_replay_idx`. Measured on PostgreSQL 18.7 over 3,000 commits, idle and tail polls dropped from `Seq Scan` + `Hash Join` reading **449 shared blocks** to `Index Only Scan` reading **6-86 shared blocks** in **0.01-0.05 ms**.
- **Bun `1.4.5` runtime pin:** Updated active CI workflows, Dockerfiles, compose examples, release-gate tests, and contributor/deployment guides from Bun `1.4.4` to `1.4.5`.

## Core lease fencing, SQLite durability, flows, and multi-broker hardening

- **Atomic lease fencing inside `processingLocks`:** `ack`, `fail`, `ackBatch`, `moveJobToDelayed`, `moveActiveToWait`, `moveToWaitingChildren`, `discardJob`, and `updateJobProgress` now re-validate active status and lease tokens inside `processingLocks`, preventing a paused stale worker from interfering with a successor's active delivery. Expired active locks are tracked in a WeakMap so `getLockInfo` returns `null` while `checkExpiredLocks` reclaims the job and stale workers remain fenced, and unexpired stall-retry guard locks survive `cleanOrphanedJobLocks`.
- **SQLite durability and live custom-ID ownership past 50,000 entries:** `discardJob` commits DLQ insertion and `jobs` deletion in one `commitFailedJob` transaction and `recoverPendingJobs` skips `dlqJobIds` so crash-split databases never resurrect DLQ jobs. `promoteJob`/`promoteJobs` persist inside `shardLocks`, `WriteBuffer` clears stale pending entries after durable writes and keeps `_diskFull` set until `onFlushSuccess`, and `handleCustomId`/`getJobByCustomId` fall back from `customIdMap` LRU eviction to authoritative `jobIndex` lookup past the 50,000-entry default cap.
- **Parent-child flows and dependency promotion:** Re-pins `completionPins` when returning a promoted parent to `waiting-children`, clears stale `flow_failures` atomically on admission, terminal transitions, and recovery, reconciles forward dependencies on reused custom IDs within `pushBatch`, and makes SQLite/memory `removeUnprocessedChildren` atomic across shards.
- **PostgreSQL multi-broker coordination:** Persists `manuallyParked` on `movePostgresJobToWaitingChildren`, adds monotonic `supersedeSeq` to `PostgresProjectionRefreshes` and prunes dead `activeTokens`, honors `AbortSignal` and generation guards in PostgreSQL `WaitJob`, enforces monotonic `last_seen` updates in `savePostgresWorker`, and takes `FOR UPDATE` on `bunqueue_queue_state` for grouped claims (`includeGroups`).
- **Workflow and saga recovery:** Resumes `running` child executions when their parent is parked in `compensation-stuck`, awaits active child compensation claims (`LostCompensationClaim.settled`) and reloads the child row, persists loop records and `loopItem`/`loopIndex` metadata atomically across `doUntil`/`doWhile`/`forEach`, matches parked `waitFor` event names in `recordSignal`, clears wait timers only after durable resume enqueue, and enforces atomic state and `current_node_index` checks in `parkForSignal`.

## Before you upgrade

- **Remote `ExtendLock`, `ExtendLocks`, and duration-bearing `JobHeartbeat` require a non-empty lock `token`:** Missing or empty tokens now fail on `ExtendLock` and duration-bearing `JobHeartbeat` (`Lock token required for job <id>`) and are skipped in `ExtendLocks`. Tokenless `JobHeartbeat` without a `duration` stays accepted. On PostgreSQL, `JobHeartbeat` with `duration: 0` preserves `leaseDurationMs` instead of shrinking the lease to `1 ms`.
- **Active lease fencing and stall-retry tokens:** `ack`, `fail`, `ackBatch`, `moveJobToDelayed`, `moveActiveToWait`, `moveToWaitingChildren`, `discardJob`, and `updateJobProgress` throw `Lock token required for job <id>` or `Invalid or expired lock token for job <id>` on missing or stale tokens. Bogus non-empty tokens on unlocked stall-retried jobs are rejected while tokenless late-ACK compatibility on unlocked stall-retried jobs is preserved.
- **Automatic Workflow Engine Schema v2 migration:** `workflow_executions` (SQLite) and `bunqueue_workflow_executions` (PostgreSQL, advisory-locked with transactional backfill) migrate automatically on startup to add `needs_rollback`, `idempotency_key`, `definition_hash`, and O(active) partial indexes. No manual DDL is needed.
- **`StepOptions.inputSchema` fail-fast and interrupted-step retry errors:** Failed `inputSchema` validation terminates on attempt 1 instead of consuming retries on immutable input. Interrupted steps that exhaust their cumulative `retry` budget now report an explicit attempt diagnostic instead of `'Step failed'`.
- **Workflow Engine PostgreSQL exclusivity and async methods:** Passing both `EngineOptions.postgres` and `dataPath` throws `Cannot configure both "postgres" and "dataPath" on Engine`. On PostgreSQL, synchronous inspection/maintenance methods (`getExecution()`, `listExecutions()`, `cleanup()`, `archive()`, `getArchivedCount()`) throw and require their `*Async()` counterparts; synchronous SQLite callers are unchanged.
- **MCP workflow PostgreSQL fail-closed zero-DDL:** Setting both `BUNQUEUE_MCP_WORKFLOW_DB` and `BUNQUEUE_MCP_WORKFLOW_POSTGRES_URL` throws at startup. With `BUNQUEUE_MCP_WORKFLOW_POSTGRES_URL` (and optional `BUNQUEUE_MCP_WORKFLOW_POSTGRES_NAMESPACE`, default `'default'`), the MCP server never executes DDL and fails closed if `bunqueue_workflow_executions` does not exist; initialize the schema with the application `Engine` first.
- **Runtime and CLI notes:** Official Docker images and CI run Bun `1.4.5` (up from `1.4.4`) with PostgreSQL `16` through `19` (`19.0`). `bunqueue top` (`--workflow-db` and `--workflow-pg` mutually exclusive, zero-DDL fail-closed) exits `0` on clean quit or snapshot, `1` on connection/auth/runtime error, and `2` on invalid flags. `bunqueue doctor` preserves default HTTP `/health` behavior and adds opt-in deep probes (`--deep`, `--tcp`, `--sqlite`, `--pg`, `--systemd`, `--http-port`, `doctor --help`), exiting `2` on invalid flags.

## Other improvements and documentation

- **Redesigned full-width documentation homepage and full audit:** Shipped a full-width, dual-theme "Live Mission Control" homepage featuring a multi-mode install deck, interactive code trace stage, live `bunqueue top` browser simulator with 6 guided presets (including `[7] Workflows & Signals`), 4-tile architecture Bento grid (deployment spectrum, interactive Saga rollback diagram, 8 runtimes + 79 MCP tools, and measured BullMQ bars), production installer deck, and 3-step quickstart; also resolved over 440 accuracy and coverage gaps across 177 files (including Go, PHP, and Python SDK READMEs).
- **SEO and responsive layout hardening:** Expanded `BreadcrumbList` JSON-LD across all 11 indexable section hubs, ordered all 115 non-blog pages in `/llms-full.txt`, aligned mobile/tablet layouts across `320px` to `1440px` (`40px` menu button hidden above `50rem`, header navigation restored at `64rem` / `1024px`), refreshed `releaseMeta.json` (260 versions, 191 tagged), and added inline SVG diagrams to the [v2.9.23 release post](https://bunqueue.dev/blog/bunqueue-v2-9-23/).
- **CI cleanup:** Removed the automatic PR `.github/workflows/claude-code-review.yml` workflow (`claude.yml` remains available for explicit `@claude` mentions).

## Thanks to 1 contributor!

- [@egeominotti](https://github.com/egeominotti)

---

[← bunqueue v2.9.23](https://bunqueue.dev/blog/bunqueue-v2-9-23/) · [Full changelog](https://bunqueue.dev/changelog/) · [All posts](https://bunqueue.dev/blog/)
