JobQueueOptions.drainRequeue property
Put jobs the drain gave up on back on the queue before exiting.
Signature:
drainRequeue?: boolean;
Default Value
the IMQ_DRAIN_REQUEUE environment variable, itself true
Remarks
Under safe delivery this is not what brings an abandoned job back — the lease is. A job the drain abandons at its budget is still checked out to this worker, because its handler has not settled, and once the process exits the watcher returns it to the queue on its next sweep. Re-pushing it here as well delivers it twice: once from the re-push and once from the lease recovery — and the abandoned handler may still complete before the exit, so the same job can execute up to three times.
It is the sole recovery only with safe delivery off (JobQueueOptions.safe false), where nothing else holds the job. With safe delivery on — the default — turn it off, or accept the extra copy as part of the at-least-once contract handlers already have to survive.
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.