Skip to content

feat: add cancelConsumersOnSigterm option (DS-3369) - #92

Merged
nikosd23 merged 2 commits into
masterfrom
feature/sigterm-opt-out
Oct 14, 2026
Merged

nikosd23 merged 2 commits into
masterfrom
feature/sigterm-opt-out

Conversation

@ikarachristos

@ikarachristos ikarachristos commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Since 5.9.2, Rabbit cancels every consumer it created on SIGTERM. That's the right default, but it breaks processes that have their own SIGTERM hook which waits on messages from those queues.

maestro is one (Workable/maestro#1196, DS-3369). eip-redis PubSub's SIGTERM hook waits for every held throttled event to be processed before exiting. Those events only complete when an eip-rabbit Timer message arrives on a queue created through this Rabbit. Once that consumer is cancelled the wait never ends, and the pod hangs until SIGKILL and drops the events.

  • New constructor option cancelConsumersOnSigterm, default true. With false, the SIGTERM listener isn't registered, which matches the behaviour before 5.9.2. close() works either way.
  • README: the option is in the connection example, and there's a short "Shutdown" section explaining when to turn it off. Listed under v5.11.x, since it adds public API.

Testing

  • npm test on RabbitMQ 4.2.1: lint passes, 124 tests pass.
  • New test: with the option off, no SIGTERM listener is added and a queue's consumer isn't unsubscribed. The existing tests cover the default path, where the listener is registered, removed on close(), and unsubscribes every queue.

Notes

  • It's all or nothing per Rabbit instance. With false, every queue keeps consuming until the app closes the connection. That's how maestro behaved before 5.9.2. A per-queue exemption, or a public cancelConsumers() the app calls after its own drain, would be more precise. I left those out to keep this small.
  • No version bump. Release is up to the maintainers; semver says 5.11.0.

🤖 Generated with Claude Code

ikarachristos and others added 2 commits October 14, 2026 09:31
…onsumer cancel (DS-3369)

Processes with their own SIGTERM hook that waits on messages from these
queues (e.g. eip-redis PubSub draining throttled events through eip-rabbit
Timer queues) hang until SIGKILL once the consumers are cancelled.
On by default, so existing behaviour is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…alse; list option under v5.11.x

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation is backward-compatible, focused, documented, and adequately tested.

0 open findings

What changed in this PR

Adds an opt-out for automatic consumer cancellation on SIGTERM, preserving existing behavior by default.

Changes:

  • Adds cancelConsumersOnSigterm, defaulting to true.
  • Tests the disabled-listener behavior.
  • Documents shutdown behavior and configuration.
File Description
ts/​rabbit.ts Conditionally registers the SIGTERM handler.
test/​rabbit.test.ts Covers the opt-out behavior.
README.md Documents the new option and shutdown guidance.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@nikosd23
nikosd23 merged commit b0b804a into master Oct 14, 2026
8 checks passed
@nikosd23
nikosd23 deleted the feature/sigterm-opt-out branch October 14, 2026 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants