Worker
runWorker options and the worker handle.
runWorker options and the worker handle.
const worker = queue.runWorker(options?: WorkerRunOptions): Worker;Starts a background worker over the Rust core and returns a handle.
WorkerRunOptions| Option | Type | Default | Description |
|---|---|---|---|
queues | string[] | ["default"] | Queue names to serve. |
channelCapacity | number | 128 | In-flight dispatch channel capacity. |
batchSize | number | 1 | Jobs claimed per scheduler poll. |
advanceWorkflows | boolean | true | Drive workflow bookkeeping. |
mesh | MeshWorkerConfig | — | Join a mesh. |
pushDispatch | boolean | false | Wake the scheduler on enqueue instead of polling. Needs an addon built with the push-dispatch cargo feature; ignored otherwise. |
MeshWorkerConfigport, seeds, steal, encryptionKey, bindAddr, advertiseAddr,
affinityWeight, localBuffer, stealBatch, stealThreshold, virtualNodes,
stealRateLimit.
Worker| Method | Description |
|---|---|
stop() | Drain and shut down the scheduler + heartbeat. Returns a Promise<void> that resolves once worker-scoped resources are disposed. |
const worker = queue.runWorker({ queues: ["default", "emails"] });
process.on("SIGTERM", () => worker.stop());Dispatch, the heartbeat and log consumers halt synchronously, so ignoring the
returned promise is safe. await worker.stop() when you need worker-scoped
resource teardown to have finished — test teardown, or a graceful shutdown that
exits right after. It never rejects: teardown failures are logged.
The worker registers + heartbeats (5 s) so it appears on the dashboard Workers
panel; stop() unregisters it.