Skip to content

feat: gracefully shutdown redis connection on nestjs shutdown#289

Closed
nidomiro wants to merge 1 commit intonest-modules:mainfrom
nidomiro:feat/add_lifecycle_methods
Closed

feat: gracefully shutdown redis connection on nestjs shutdown#289
nidomiro wants to merge 1 commit intonest-modules:mainfrom
nidomiro:feat/add_lifecycle_methods

Conversation

@nidomiro
Copy link
Copy Markdown

@nidomiro nidomiro commented Sep 4, 2024

This PR introduces a graceful shutdown of the redis connections this module creates.
Shutting the connections down will prevent error logs on shutdown e.g. in a kubernetes cluster with itstio.

juandav added a commit that referenced this pull request Mar 22, 2026
…dling

- Add OnApplicationShutdown to RedisCoreModule for graceful Redis disconnection (PR #289)
- Fix health provider to use configured Redis connection instead of default localhost (PR #281)
- Add null-safe error handling in RedisHealthIndicator (PR #288)
- Export redisHealthIndicatorProvider from index

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@juandav
Copy link
Copy Markdown
Member

juandav commented Mar 22, 2026

Hi @nidomiro, thank you for this excellent contribution! 🙏

Your graceful shutdown implementation has been incorporated into the main branch as part of a major monorepo migration (commit 04b2720). The OnApplicationShutdown lifecycle hook is now part of RedisCoreModule, ensuring Redis connections are properly closed on application teardown.

Key changes adopted from your PR:

  • RedisCoreModule now implements OnApplicationShutdown
  • Connection tokens are tracked and all connections are gracefully closed via quit() on shutdown
  • This resolves the Jest open handles issue and enables clean Kubernetes/Istio shutdowns

Closing this PR as the changes have been merged directly. Thank you for your contribution!

@juandav juandav closed this Mar 22, 2026
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.

2 participants