JobQueueOptions.safe property

Whether a job is handed to a worker under a lease, so that a worker dying at any point before its handler settles does not take the job with it.

Signature:

safe?: boolean;

Default Value

true

Remarks

When safe delivery is enabled a job is moved atomically out of the queue into a worker-owned key as it is popped, and that key is held until the onPop handler's promise settles. A process that dies before then — before the handler starts, part-way through it, SIGKILL included — leaves the job checked out to a worker that no longer exists, and the watcher moves it back onto the queue for another worker on its next sweep, once the owner has left the broker's client list. The guarantee covers the processing, not only the hand-off.

It does not make the attempt finish: a recovered job runs again from the start, so delivery is at-least-once and handlers must be idempotent. JobQueueOptions.drain is the complement for an orderly shutdown — it lets the running handler complete instead of being re-run elsewhere.

The behaviour is @imqueue/core's and its contract is documented there: IMQOptions.safeDelivery. This package defaults it to true while core defaults to false — a job queue is the case where the extra round-trip is worth it.

Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.