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
This closes the hole the drain itself opens. Safe delivery releases a job's worker key as soon as the job reaches the handler, so a job the drain abandons at its budget is not checked out to anybody and nothing re-queues it — it is simply gone. Re-pushing it on the way out makes that attempt recoverable.
The cost is the usual at-least-once one, and it is worth stating plainly: the abandoned handler is still running when its job is pushed back, so the job can both complete and be delivered again. That is the same duplicate a lease expiry would produce, and the reason handlers must be idempotent.
Turn it off if a duplicate is worse than a lost attempt.
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.