JobQueueOptions.drain property

Drain jobs still being handled before shutting down on SIGTERM/SIGINT, instead of exiting from under them.

Signature:

drain?: boolean;

Default Value

the IMQ_DRAIN_ENABLE environment variable, itself false

Remarks

Opt-in, and nothing about a queue with it off differs from before it existed. Left off, @imqueue/core's own signal handlers release the watcher locks and exit without waiting, so a job in flight loses that attempt.

Turned on, SIGTERM and SIGINT instead stop popping, wait up to JobQueueOptions.drainTimeout for the handlers already running — including the re-schedule a handler asked for — then release the connection and exit 0. Enabling it also suppresses the queue layer's own handlers, which would otherwise exit the process mid-drain.

Every drain-enabled queue in the process drains together under one signal handler, so a publisher and a worker side by side do not exit from under each other.

Delivery stays at-least-once. A drain narrows the window in which an attempt is lost; it does not close it.

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