45 stability bugs. 1.95M-job torture. Zero breaking API changes.
How we audited bunqueue from TCP wire framing down to SQLite write buffers, PostgreSQL lock ordering, and nested workflow recovery, then built a six-layer verification gauntlet before shipping it in v2.9.23.
Production reliability in a job queue rarely breaks on the happy path. It breaks when a disk fills during a buffered write, when a slow SSE client stops reading, when obliterate() races with a delayed retry, when an auto-ACK fails after a job has already finished, or when a workflow engine restarts halfway through nested child compensation.
Over four focused waves, we audited bunqueue from wire framing down to SQLite write buffers, PostgreSQL lock ordering, and workflow crash recovery. The campaign landed 45 confirmed stability fixes across 72 source files (+1,095 / -436 lines), 48 new regression tests across 10 test files (3,151 lines), and 16 updated internal technical references. Public API signatures, normal-path defaults, and scheduling semantics did not change (every failure-path and validation guardrail is listed in the v2.9.23 upgrade notes).
All 45 fixes ship in bunqueue v2.9.23, with every detail recorded in the changelog. Before tagging the release, we subjected the final tree to a six-layer test and torture campaign spanning deterministic reproduce-first regressions, heavy fast-check state-machine models, a 5-minute 1,952,622-job continuous endurance marathon, extreme connection/backpressure torture, hyper-advanced distributed systems fault injection, real Linux kernel ENOSPC, a 10-broker PostgreSQL 18.7 crash soak, all 6 official SDKs, and controlled A/B benchmarks on both Linux and macOS.
Methodology: prove it fails three times, or it is not a bug
Section titled “Methodology: prove it fails three times, or it is not a bug”Static code audits often produce plausible-looking “fixes” that mask guesswork or silently alter intended semantics. To keep every change grounded in observable failure, every candidate defect had to clear four hard rules:
- Three independent RED runs on Linux first. Each regression test ran against the untouched
53be601bbaseline on a dedicated Debian 13.7 VM (x86_64, AMD Ryzen 9 9950X, 16 vCPU, 15 GiB RAM, Bun 1.4.5; containerized sandboxes ran the repository’s pinned Bun 1.4.4). Anything that could not fail deterministically 3/3 times on baseline was rejected. - Pure stability only. No business-logic changes, no public signature changes, no modified expectations in existing tests, and no source file allowed past the repository’s 300-line ceiling (the largest touched
src/files aresrc/client/sandboxed/runtime/pool.tsandsrc/application/lockManager.ts, tied at 299 lines). - Three independent GREEN runs plus full suites on Linux. After fixing each wave, the regression tests plus companion suites had to pass 3/3 times on the Debian 13.7 VM, alongside the full VM embedded (43/43 suites, 349/349 tests) and TCP (69/69 suites, 553/553 assertions) suites.
- Model, sandbox, and adversarial review gates. Every engine, persistence, and client wave ran the
fast-checkstate-machine campaign (bun run test:modelagainst a real TCP broker and SQLite), the full containerizedbun run test:sandboxsuite (unit,tcp,embedded), and an adversarialskepticreview untilPASS. Every wave failed round 1 of skeptic review on real edge cases, fixed them, and re-gated before passing round 2.
| Wave | Subsystem | Bugs fixed | New regression tests | src/ files | test:model | Wave test:sandbox (unit / tcp / embedded) |
|---|---|---|---|---|---|---|
| Wave 1 | Server transport, WS/SSE, WaitJob, Cloud | 9 | 9 | 17 | N/A | 12,010 / 553 / 349 (0 fail) |
| Wave 2 | Core queue engine, races, wakes, cleanup, cron | 14 | 17 | 22 | 12/12 (104,965 asserts) | 12,027 / 553 / 349 (0 fail) |
| Wave 3 | SQLite & PostgreSQL persistence | 12 | 12 | 17 | 12/12 (102,039 asserts) | 12,039 / 553 / 349 (0 fail) |
| Wave 4 | TCP client, Worker, SandboxedWorker, Batch, Workflow | 10 | 10 | 16 | 12/12 (93,177 asserts) | 12,049 / 553 / 349 (0 fail) |
| Total | End-to-end broker, persistence, and client | 45 | 48 | 72 | All green | 12,049 / 553 / 349 (0 fail) |
Wave 1: Server transport crash-safety, backpressure, and cancellation
Section titled “Wave 1: Server transport crash-safety, backpressure, and cancellation”The edge of a broker faces malformed frames, abruptly closed sockets, and consumers that stop draining their stream. Wave 1 closed nine failure paths across TCP, WebSocket, SSE, WaitJob, Prometheus label rendering, and Cloud telemetry senders.
The sharpest crash came from a single malformed wire field: if a client sent a non-string reqId whose value could not be MessagePack-encoded (such as a >64-bit BigInt), the TCP handler’s error path threw while serializing the error response itself, surfacing as an unhandledRejection capable of bringing down the server. Normalizing reqId before routing and guarding the error-write fallback eliminates that crash surface. On the same TCP path, pipelined frames now stop processing once a connection disconnects or drops on write overflow, and SubscribeEvents on a closed socket no longer registers an orphaned global event bridge.
SSE broadcasts previously had no backpressure ceiling: a single stalled consumer accumulated queued frames in memory without bound. Streams now enforce a 1 MiB ByteLengthQueuingStrategy high-water mark (SSE_MAX_BACKPRESSURE_BYTES), dropping overflow chunks into SseHandler.droppedMessages, capping reconnect replay for stalled clients, and probing backpressured streams with a zero-byte heartbeat chunk so dead sockets are pruned cleanly.
| Area | Before | After |
|---|---|---|
TCP reqId & pipelining | Unencodable reqId triggered unhandledRejection; pipelined frames kept running after close/overflow and leaked SubscribeEvents bridges | Non-string reqId normalized; error-write fallback guarded; pipelined loop aborts on close/overflow; closed sockets never bind global event bridges |
| WebSocket async replies | Direct ws.send() after await could reject unhandled on disconnect races | Guarded across WsHandler.onMessage, ws/subscriptions.ts, and http.ts |
| SSE backpressure | Unbounded memory buffering on stalled clients | 1 MiB high-water mark, tracked drops (droppedMessages), bounded replay, zero-byte heartbeat pruning |
WaitJob cancellation | Disconnected HTTP/WS/TCP callers held waiters and timers up to 10 minutes on memory/SQLite | Wired to context.connectionSignal; waiters and timers release immediately on disconnect (PostgreSQL multi-broker waitForJobResult unchanged) |
Queue names & /prometheus | Non-string wire queue names could reach Prometheus escapeLabel and throw (including null-prototype objects) | validateQueueName rejects non-string wire values while preserving 'Queue name is required'; escapeLabel coerces safely |
| Cloud senders | WsSender.cleanup() left ws.onopen and post-await dispatch active; failed HttpSender flushes lost chronological order and leaked 2xx bodies; CloudAgent.stop() sent HTTP when useHttp: false | onopen and post-await handlers guarded against stopped/stale sockets; failed flushes re-inserted at the buffer front; 2xx bodies cancelled; useHttp: false respected on stop |
Wave 2: Core queue engine races, missing wakes, cleanup leaks, and cron
Section titled “Wave 2: Core queue engine races, missing wakes, cleanup leaks, and cron”Inside the broker, invariants span several structures at once: priority heaps, jobIndex, processing maps, temporal indexes, group/concurrency counters, and long-poll waiters. Wave 2 resolved 14 defects where those structures drifted under concurrency or cleanup.
Two races stood out. First, cleanOrphanedJobIndex Phase 3 deleted entries without re-checking ownership under shardLocks or consulting waitingDeps and waitingChildren, which could evict parked dependency/flow parents or jobs concurrently pulled by a worker and allocate ghost queue maps as a side effect. Second, obliterate() could race with moveJobToDelayed, moveActiveToWait, moveToWaitingChildren, and discardJob: once the shard lock was re-acquired, those mutations could resurrect an obliterated job, allocate a ghost WaiterManager, or write to SQLite outside the shard critical section. Revalidating jobIndex under shardLocks, running queued discardJob within a single shard write lock, and ordering in-memory cleanup and notifications before synchronous SQLite writes closed both races.
We also fixed four missing shard.notify(job.queue) wakes (in stallDetection, lockManager for DLQ bound expiry and protected cron retirement, clientTracking for disconnect release, and dlqRetry) that left long-polling workers asleep even after work was re-queued or a concurrency slot freed.
| Area | Before | After |
|---|---|---|
Orphan index & obliterate() races | cleanOrphanedJobIndex could delete live parents or pulled jobs; transition helpers could resurrect obliterated jobs or leave ghost WaiterManager state | Revalidated under shardLocks with waitingDeps/waitingChildren checks; queued discardJob atomic under one shard lock; ShardLifecycle.obliterate clears waiter state |
| Delayed counters & wakes | changeWaitingDelay drifted delayed metrics and missed wakes; zero-backoff failJob incremented delayed metrics; four recovery paths missed shard.notify | ShardMetrics.updateDelayed synced; failJob passes job.runAt > now; wakes fire before throwing storage writes in stall, lock, disconnect, and DLQ retry paths |
CronScheduler | Overlapping tick() runs could double-fire; remove+add kept stale lastFiredAt; persistCron failures spun at 0 ms; exhausted nextRun <= 0 schedules stayed in cronHeap | tick() serialized; generation guarded before recording lastFiredAt or re-inserting; CronRuntime.add() clears lastFiredAt; 1,000 ms backoff on persistCron errors; exhausted schedules excluded at runtime and load |
| Cleanup & auxiliary structures | Orphaned temporalIndex entries starved cleanQueue; drain/clean/cancel/TTL leaked uniqueKey, customIdMap, and dependencyResults; backward clock jump stalled RateLimiter.refill(); orphanRecovery skipped startedAt === 0; TTLMap.has() broke on undefined; late tokenless timeout ACKs could phantom-complete retries | Orphaned temporal entries pruned; all owned indexes released on removal/expiry; monotonic guard on clock jumps; startedAt === 0 treated as active; TTLMap.has() + churn compaction fixed; retryAttempt tracked on retired timeout generations |
Wave 3: SQLite and PostgreSQL persistence crash-safety and lock order
Section titled “Wave 3: SQLite and PostgreSQL persistence crash-safety and lock order”Persistence defects hurt most when storage is already under stress. Wave 3 fixed 12 bugs split across the SQLite write buffer/serializer and the PostgreSQL multi-broker store/manager.
On SQLite, the most severe bug lived in WriteBuffer: commitFailedJob, requeueDlqJob, purgeDlqEntries, deleteJob, and commitRemovedCompletion removed pending buffered entries before calling safeWrite. If disk space ran out (SQLITE_FULL) and safeWrite failed, the buffered job was already gone from memory and never reached disk: silent data loss. Pending entries are now removed only after safeWrite commits. Nearby, WriteBuffer.stopGracefully() now clears backoffTimer on both normal completion and timeout, SqliteMutations.updateForRetry stamps buffered state 'waiting', flushes pending inserts, and clears started_at = NULL, and SqliteState sets PRAGMA busy_timeout = 5000 before schema checks while isolating the remaining PRAGMAs individually.
On PostgreSQL, removePostgresChildDependency promoted a parent without checking parentRow.state === 'waiting-children', which could resurrect an active, completed, or failed parent and leave stale rows in bunqueue_flow_failures. Meanwhile, changePostgresPriority, changePostgresDelay, and retryPostgresTerminalJob could demote jobs whose dependencies were already satisfied, and retryPostgresTerminalJob risked lock-order inversion until dependency-completion advisory locks were acquired ahead of row locks.
| Backend | Before | After |
|---|---|---|
| SQLite write buffer & retry | Failed safeWrite (SQLITE_FULL) dropped pending buffered jobs; stopGracefully() leaked backoffTimer; updateForRetry left stale started_at or unflushed inserts | Pending entries removed only post-commit; backoffTimer always cleared; updateForRetry flushes buffered inserts, stamps 'waiting', and clears started_at = NULL |
| SQLite startup, pagination & blobs | Schema check ran before busy_timeout; getJobs passed negative or NaN LIMIT/OFFSET; corrupt/non-array MessagePack blobs threw; loadActiveJobs and getDlqEntry lacked tie-breakers | busy_timeout = 5000 first and per-statement PRAGMA isolation; invalid/reversed/non-positive bounds return [] with start >= 0; corrupt blobs guarded; deterministic id tie-breakers added |
| PostgreSQL flows & mutations | removePostgresChildDependency could resurrect non-waiting-children parents; priority/delay/retry mutations broke ready states for satisfied dependencies; retryPostgresTerminalJob risked lock-order deadlocks | Requires parentRow.state === 'waiting-children', cleans bunqueue_flow_failures, emits updated; preserves satisfied-dependency ready states across priority, delay, and retry mutations, and acquires dependency-completion advisory locks before row locks in retryPostgresTerminalJob |
| PostgreSQL metrics, tokens & deferred writes | getPostgresQueueMetrics used unsafe array spreads and unchecked sparse indices; forgetToken cleared another worker’s active token; deferred drain/obliterate failures left stale projections; retained failures grew unbounded | Direct bounded bucket construction against maxMetricDataPoints; forgetToken guarded by active-token ownership; projectionRefreshes.supersede + finally snapshot reconciliation; 1,000-entry cap on retained deferred failures |
Wave 4: TCP clients, workers, sandboxed pools, batches, and workflow recovery
Section titled “Wave 4: TCP clients, workers, sandboxed pools, batches, and workflow recovery”The final wave audited the client runtime, worker pools, Simple Mode batching, and Workflow Engine crash recovery, resolving 10 bugs that caused callers to hang, emit false failures, or stall on restart.
In Worker, a completed job could still be marked FAIL on the broker if its subsequent auto-ACK failed or if a user’s completed listener threw, because both ran inside the processor’s try/catch feeding handleJobFailure. Auto-ACK and completed emission now run outside the processor failure boundary, and errors are wrapped in a fresh contextual Error (context: 'ack', 'ack-stale', or 'completed-listener') via withErrorContext() so shared AckBatcher failure instances are never mutated across jobs.
In Worker native batching, configuring batch.size larger than limiter.max livelocked because the batch waited forever for more tokens than the limiter could ever hold, and groupLimiter was not enforced across all candidate jobs in startBatch(). Capping batch assembly at min(batch.size, limiter.max), computing NaN-safe multi-slot waits in WorkerRateLimiter.getTimeUntilNextSlot(), and tracking tentative per-group counts across every batch candidate fixed both issues.
In the Workflow Engine, restarting a parent whose owned child had crashed mid-compensation (persisted as compensating, or failed with rollbackStatus === undefined) caused adoptExistingChild() to poll passively until the sub-workflow timed out. adoptExistingChild() now runs inside runSubWorkflow’s try/catch boundary and invokes recoverChildCompensation() (guarded by fence.assertActive()), resuming interrupted rollback and settling sub:<name> as failed (parking the parent cleanly in compensation-stuck) if recovery cannot proceed, for example when the child workflow is no longer registered.
| Component | Before | After |
|---|---|---|
TcpClient | Concurrent connect() waiters hung on connect/auth failure or forceReconnect(); encode/write throws stalled processQueue(); client FrameSizeError left desynced sockets open | connectWaiters rejected on failure and in forceReconnect() (Connection lost); per-command throw isolation with removeByReqId() double-count guard; FrameSizeError clears writeQueue and terminates the socket in finally |
Worker & AckBatcher | Auto-ACK failure or throwing completed listener triggered FAIL/failed and mutated shared errors; AckBatcher.queue() after stop() armed ackTimer; batch size > limiter.max livelocked and bypassed groupLimiter | Isolated post-processor ACK and completed errors with fresh withErrorContext() wrappers; post-stop() queue() rejects immediately (preserving stop()’s silent clear of pre-existing entries); batch capped by limiter.max with multi-slot waits and per-group enforcement |
SandboxedWorker | Processor paths with apostrophes (') broke generated wrapper imports; jobs pulled after stop() started were dispatched or stalled in threadForJob() | Import specifiers serialized via JSON.stringify + \u2028/\u2029 escaping; stop() releases pulled jobs via moveActiveToWait/MoveToWait and aborts threadForJob() immediately |
BatchAccumulator & Workflow | Synchronous throws, non-array returns, or throwing result getters in flush() hung batch callers; restarted parents timed out waiting on owned children crashed mid-compensation | Synchronous try/catch + Promise.resolve(...) preserves sync call timing while settling all callers atomically on throws, non-arrays, and throwing getters; adoptExistingChild() resumes owned child compensation inside runSubWorkflow’s failure boundary |
The engineering behind the tests: a six-layer torture gauntlet
Section titled “The engineering behind the tests: a six-layer torture gauntlet”Fixing 45 individual bugs proves 45 known paths. It does not prove that fixing them left no subtle memory leak, file-descriptor leak, WAL checkpoint stall, lock inversion, partial-packet corruption, split-brain race, or hot-path slowdown under real production concurrency.
To test the system as a hostile production environment would, we built and ran a six-layer verification architecture on our dedicated Debian 13.7 VM (x86_64, AMD Ryzen 9 9950X, 16 vCPU, 15 GiB RAM, Bun 1.4.5) plus containerized sandboxes and real PostgreSQL 18.7. Each layer hunts a class of bug the previous layer cannot see:
| Layer | Failure class targeted | Engineering mechanism | Outcome on 6d7fd2e2 |
|---|---|---|---|
| 1. Reproduce-first regressions | Known bug regressions & timing flakes | 3/3 RED on baseline → 3/3 GREEN on fix + 5× --rerun-each 5 anti-flake sweep | 48/48 new tests (430/430 across 14 files in 27.03 s) |
2. Stateful fast-check models | Arbitrary command interleavings & invariant drift | Shrinking random histories against live TCP broker + SQLite + SIGKILL (3× Linux scale) | 12/12 (130,888 expect() calls in 90.52 s) |
| 3. Continuous endurance & chaos | Memory leaks, FD leaks, WAL bloat, latency drift | Multi-service simulation, 45 s kill soak (160 kills), 35× SIGKILL fuzz, 5-min 1.95M-job marathon | 0 lost jobs, FDs 12 → 84 → 12, WAL 4.05 → 4.27 MiB |
| 4. Extreme torture & distributed faults | Network fragmentation, split-brain zombies, kernel disk-full | 400 TCP storm, 100 WS + 60 SSE flood, 1-3 B TCP fault proxy, 40 zombie fences, 16 MiB tmpfs ENOSPC | 100% PASS (1,000/1,000 trickle, 80/80 fenced, 9/9 ENOSPC) |
| 5. Multi-broker PostgreSQL & 6 SDKs | Cross-process advisory locks & wire conformance | Real PostgreSQL 18.7 (10 brokers, 2 crashes) + 6 language SDKs (C01-C18, SQLite + PG) | 573/573 PG (0 deadlocks), 6/6 SDKs PASS (0 anomalies) |
| 6. Controlled A/B benchmarks | Unintended hot-path overhead | Same-machine baseline (53be601b) vs hardened (6d7fd2e2) on macOS M5 Max & Linux 9950X | Zero regression across SQLite, TCP, getJobs, Workflow |
Layer 3 in detail: why unit tests miss leaks, and how the 5-minute 1.95M-job marathon hunts them
Section titled “Layer 3 in detail: why unit tests miss leaks, and how the 5-minute 1.95M-job marathon hunts them”Short tests tear down the broker before GC cycles settle, before SQLite WAL files cross checkpoint thresholds, and before leaked timers or socket descriptors accumulate. To expose slow leaks, we ran three escalating endurance profiles against a real TCP+HTTP broker backed by SQLite on Debian 13.7:
- Multi-service production simulation: Ran realistic services simultaneously against one broker: a 50,000-job flash-sale burst (7.19 s, 6,952 jobs/s, p50 1,620 ms, p99 1,994 ms), 11,500 multi-tenant jobs + 500 DLQ across 3 hard-killed workers, 100 Flow DAGs (400 nodes), 150
SandboxedWorkerjobs (with an apostrophe in the processor path and a rolling restart), 65 TCP Workflows (30 linear, 20 signal, 15 nested rollbacks executing 30/30 child compensations), 5/5 exact cron ticks, 191,439 WebSocket events, 20 intentionally stalled SSE clients, 43/43/prometheusscrapes, and a liveSIGKILLmid-stream recovering 1,000/1,000 durable payments (RSS 63.6 → peak 461.2 → 419.5 MiB, FDs 12 → peak 75 → 55). - Extended chaos soak & 35-cycle SIGKILL fuzzing:
test/repro-chaos-soak.test.tsatSOAK_MS=45000/SOAK_KILL_MS=250completed 30,000/30,000 jobs (30,045 assertions) while violently killing a worker 160 times (WAL 4.1 → 4.3 MB, probe latency p50 0.041 → 0.044 ms, p99 0.161 → 0.151 ms), followed bytest/repro-chaos-crash-recovery.test.tsatCRASH_CYCLES=35(7/7, 4,473 assertions, 0 durable losses) and 83/83 fault-injection, WAL-truncation, corrupt-WAL-header, and write-contention tests (947 assertions). - 5-minute continuous endurance marathon (1,952,622 jobs): Rather than stopping after one burst, the marathon ran continuously for 300 s of mixed production traffic plus full drain (410 s total) onto a 2.12 GiB SQLite database while sampling
/proc/<pid>/status(RSS),/proc/<pid>/fd(exact kernel open file descriptors), database + WAL file sizes, and synthetic end-to-end probe latency every 5 s (59 samples):
| Marathon telemetry (59 samples, 410 s total) | Start | First-half median | Second-half median | Peak / Steady | Post-drain |
|---|---|---|---|---|---|
| Broker RSS | 64.1 MiB | 521 MiB | 571.9 MiB | 650.8 MiB | 516.9 MiB |
Kernel open FDs (/proc/<pid>/fd) | 12 | 84 | 84 | 84 | 12 |
| SQLite WAL size (on 2.12 GiB DB) | 4.05 MiB | N/A | N/A | 4.27 MiB | 4.27 MiB |
| End-to-end probe latency (p50 / max p99) | N/A | 7.00 ms | 5.35 ms | 42.96 ms max p99 | N/A |
Over those 410 seconds, the broker pushed and 100% drained 1,952,622 jobs (0 lost, 0 stuck), weathered 8 flash-sale burst waves (20,000 jobs each), 19 forced worker kills, 6,465/6,465 DLQ verifications, 450 Flow DAGs (1,800 nodes), 3,000 SandboxedWorker jobs, 156 Workflows (72/72 compensations), 604 cron ticks, 59,025,290 WebSocket events, 30 rotated stalled SSE tabs, 1,448 hostile/corrupt TCP frames rejected without dropping healthy clients, 362/362 HTTP pushes and /prometheus scrapes, and 3 consecutive broker SIGKILL cycles recovering 3,000/3,000 durable jobs. Open file descriptors returned from 84 to exactly 12 (zero leaked sockets, timers, or handles), and the SQLite WAL stayed flat between 4.05 and 4.27 MiB while the main database grew past 2.12 GiB.
Layer 4 in detail: hostile networks, zombie workers, nested crashes, and real Linux ENOSPC
Section titled “Layer 4 in detail: hostile networks, zombie workers, nested crashes, and real Linux ENOSPC”Standard integration tests run over clean loopback TCP with well-behaved clients and plenty of disk space. Layer 4 broke every one of those assumptions:
- Extreme broker torture:
- 400-client TCP connect/push/disconnect storm: open FDs stayed at 12 → 12.
- 100 concurrent WebSocket subscribers + 60 intentionally stalled SSE clients under a 10,000-job flood: 1,842,200 WebSocket messages delivered, open FDs 12 → 11, broker RSS 126.4 MiB (proving the Wave 1 1 MiB SSE backpressure ceiling prevents OOM even with 60 dead SSE readers).
- 200 concurrent
obliterate(),drain(),clean(),pause(), andresume()operations fired against 6 queues with active workers (postObliterateClean: true, zero resurrected jobs or ghost waiters). - 100,000-job backlog (1-4 KiB payloads): pushed in 1,593 ms (62,775 ops/s), drained in 7,819 ms (12,789 ops/s), 617.8 MiB peak RSS, with reversed/negative pagination bounds returning
[]. - 10 live TLS
SIGHUPcertificate rotations under active HTTPS traffic: 8 valid rotations served new certificates without dropping open sessions and 2 corrupted cert/key pairs were refused atomically while keeping the previous certificate live.
- Lossless TCP fault proxy (1-3 B trickle + 2.5 s silent blackhole +
RST): To test real wire reassembly and reconnect recovery, we placed a custom TCP fault proxy between clients and the broker. An engineering lesson surfaced immediately: our first naive proxy split frames into 1-3 byte chunks in a tight loop callingsocket.write()without tracking partial writes, causing the proxy itself to drop bytes under kernel socket backpressure. Rewriting the proxy around bunqueue’s ownSocketWriteQueuemade the adversarial wire transport lossless. Once the test harness stopped dropping bytes, bunqueue processed 1,000/1,000 jobs over 1-3 B fragmented TCP streams and recovered 200/200 jobs after a 2.5 s silent blackhole followed by abruptRST. - 40 simultaneous split-brain zombie worker fencing races:
40 jobs were pulled with short leases, their original workers were artificially frozen past lease expiry so fresh workers legitimately took over with new lock tokens, and then the “zombie” workers woke up and fired 80 stale
ACK/FAILmutations (2 per job). The broker rejected 80/80 stale mutations with zero poisoned results. - 3-level nested workflow crash mid-compensation + operator controls:
A
parent → mid → leafworkflow crashed midway through child compensation. On restart,adoptExistingChild()resumed rollback in exact reverse order["leaf-2", "leaf-1", "mid-1", "parent-1"]without duplicating any compensation step. We also verified both operator recovery controls on stuck compensations:resumeCompensation()settled cleanly tofailed/completed, andabandonCompensation()settled cleanly tofailed/stuck. - 40 multi-queue DAGs across all 4 failure policies surviving
SIGKILL: 10 normal trees, 10ignoreDependencyOnFailure, 10removeDependencyOnFailure, and 10failParentOnFailure(routing parents to DLQ) were driven across a hard brokerSIGKILLwith 100% policy fidelity. - 3 live
VACUUM INTOSQLite snapshots under active write load: Three concurrent point-in-time SQLite backups taken while workers actively wrote and completed jobs all passedPRAGMA integrity_check === 'ok'. - Real Linux kernel
ENOSPC/SQLITE_FULL(16 MiBtmpfs,DF1-DF9): Instead of mocking a disk-full error,test/repro-disk-full.test.tsmounted a real 16 MiB Linuxtmpfsfilesystem and drove SQLite straight into the kernel wall. All 9/9 scenarios (130 assertions in 879 ms) passed: durable pushes failed loudly without leaving phantom in-memory jobs, rejected custom-ID reuse preserved prior DLQ/completed generations across restart,/healthsurfaceddiskFull, and freeing space restored clean writes.
Layer 5 & 6: PostgreSQL 18.7, 6 SDKs, anti-flake, and A/B benchmarks
Section titled “Layer 5 & 6: PostgreSQL 18.7, 6 SDKs, anti-flake, and A/B benchmarks”- Real PostgreSQL 18.7 (
postgres:18.7):bun run test:postgrespassed 572 pass / 0 fail / 1 skip (12,674 assertions across 126 files), plus the opt-in ten-broker crash soak (bun run test:postgres:ten-broker): 10 concurrent brokers, 40 consumers, 20,000 steady-state jobs at 6,546.55 jobs/s, 2 hard-crashed brokers, 5,000 recovery jobs, 200 recovered leases, 0 deadlocks, 0ackbFailures, and 0transactionRetries(573/573 total). - All six official SDKs (
bun run test:sandbox:sdk, SQLite and PostgreSQL C01-C18 conformance): overall PASS (0 anomalies on6d7fd2e2, 0 surviving processes): TypeScript 882/0/0 (Node 20/22, Deno, Bun, and Cloudflareworkerd18/18), Python 219/0/0, PHP 105/0/0, Go 114/0/1, Rust 92/0/1, and Elixir 145/0/1, plus client parity (91 client and 39 workflow canonical exports, 0 differences; 133/133 parity tests). - Full native Linux
x86_64Bun 1.4.5 & 5× anti-flake sweep: Embedded 43/43 (349/349), TCP 69/69 (553/553), WebSocket/SSE 8/8 (88/88), MCP 46/46 (576/576), Core Public API E2E (621/621), built-client/parity (149/0/2 across 17 files), and--rerun-each 5across all 10 Wave 1-4 stability files + 4 core race/lock/workflow files: 430 pass / 0 fail (2,675 assertions in 27.03 s). - Controlled A/B benchmarks (
53be601bvs6d7fd2e2): To prove 45 stability guards added zero measurable hot-path overhead, we ran alternating A/B suites on both native macOS (Apple M5 Max, 18 CPUs, 64 GiB RAM, Bun 1.4.4) and the Debian 13.7 VM (AMD Ryzen 9 9950X, 16 vCPU, Bun 1.4.5):
| Benchmark (median) | macOS M5 Max (53be601b → 6d7fd2e2) | Linux 9950X (53be601b → 6d7fd2e2) |
|---|---|---|
| SQLite durable lifecycle (5,000 × 5) | 9,153 → 9,131 jobs/s | 23,173 → 23,258 jobs/s |
| TCP serde pipelined (20,000 × 5) | 18,282 → 17,825 ops/s (p50 50 → 52 µs) | 14,771 → 14,954 ops/s (p50 98 → 99 µs, p99 523 → 501 µs) |
TCP PUSHB bulk (20,000 × 5) | 91,328 → 90,271 ops/s | 90,903 → 90,568 ops/s |
getJobs 20,000 jobs (no filter, 500 runs) | 259.7 → 259.5 µs | 302.8 → 303.1 µs (all states 193.9 → 183.7 µs) |
| TCP 50,000 push / bulk (median of 3) | 62,769 → 63,056 / 62,848 → 63,650 ops/s | 73,545 → 74,470 / 74,551 → 77,684 ops/s |
Workflow Engine (tcp/linear, 5 runs) | 1,036 → 1,040 wf/s | 2,088 → 2,110 wf/s |
Boundaries and release verification
Section titled “Boundaries and release verification”Even a six-layer torture suite stays honest about what it proves: regression tests, model campaigns, and soak runs are strong evidence for the paths and failure modes they exercise, not a mathematical proof that no undiscovered edge case exists. Every fix ships in bunqueue v2.9.23, validated locally through the repository’s containerized product and SDK sandboxes and fresh isolated Ubuntu 24.04 and Debian 13 OrbStack Machines, and shipped through green GitHub Actions CI across PostgreSQL 16, 17, and 18.6.