IMQServiceOptions.drain property
Drain in-flight requests before shutting down on SIGTERM/SIGINT instead of exiting on a fixed timer.
Signature:
drain?: boolean;
Default Value
the IMQ_DRAIN_ENABLE environment variable, itself defaulting to false
Remarks
Opt-in. Left off, a service behaves exactly as it always has: the signal handler starts destroy() without awaiting it and force-exits after IMQ_SHUTDOWN_TIMEOUT, so a handler still running is abandoned and its caller never receives a reply.
Turned on, the service stops consuming, waits up to IMQServiceOptions.drainTimeout for the handlers already running to finish and publish their replies, then tears the transport down and exits 0. Because the queue layer's own signal handlers would exit the process mid-drain, enabling this also forces to false on the service's queue.
Delivery stays at-least-once either way — a drain narrows the window in which work is lost, it does not close it.
Each process drains its own in-flight work, so under IMQServiceOptions.multiProcess every forked worker drains separately — and the cluster primary, which runs a consumer of its own, drains only what that consumer was handling.
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.