Queue
@warlock.js/queue runs background work outside the request/response
cycle — sending an invoice email, syncing inventory, generating a
report — as durable jobs stored in Redis via BullMQ
or in a local SQLite file without Redis. Both survive restarts and retry on
failure. Use the memory driver for tests that execute real handlers.
See Local and memory queues for backend selection, leases, crash recovery, and cancellation on Node >= 22.15.
This is not the same as @warlock.js/core’s Queue class, which is
an in-memory batcher inside one process (nothing stored, no retries,
lost on exit). Reach for @warlock.js/queue whenever the work must
survive a restart or be retried.
Try it in fifteen lines
Section titled “Try it in fifteen lines”import { defineConfig } from "@warlock.js/core";import { defineJob, queueConnector } from "@warlock.js/queue";
export default defineConfig({ connectors: [queueConnector()],});
// anywhere in app codeexport const sendInvoice = defineJob({ name: "invoices.send", attempts: 5, backoff: { type: "exponential", delay: 2000 }, async handle(payload: { invoiceId: string }, ctx) { await ctx.progress(50); },});
await sendInvoice.dispatch({ invoiceId: "42" }, { delay: "10m", priority: 1 });The connector starts workers once your app code (and therefore every
defineJob) has loaded, and drains active jobs on shutdown.
Read by intent
Section titled “Read by intent”- First time using it → Getting started.
- Understanding the mental model → Essentials.
- Looking up “how do I…?” → Guides.
- Copy-paste a real task → Recipes.
- Method-by-method lookup → Reference.