question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Redis client created with CacheManager (still) does not close when app quits

See original GitHub issue

Bug Report

Current behavior

This is effectively a repeat of https://github.com/nestjs/nest/issues/1621

This problem resurfaced with the 3.x release of nestjs-command https://www.npmjs.com/package/nestjs-command, which removed the { autoExit } option. Redis is still running, and prevents CLI commands from wrapping up.

Input Code

I have a sample repo if that would be helpful.

Possible Solution

@kamilmysliwiec advised “I’d suggest triggering close in the onModuleDestroy()”. I cannot figure out how to reach Redis directly via the cache manager service (also I’m unclear if he even means triggering “close” on Redis, or on a wrapping module, or…?)

I will be happy to update the documentation and post a PR upon solving this issue.

Environment


Nest version: 8.0.6
 
For Tooling issues:
- Node version: 16.4.0
- Platform:  Mac

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
EricWVGGcommented, Sep 2, 2021

jinx!

0reactions
jmcdo29commented, Sep 2, 2021

Pretty much! I’m going to close this out as it seems there isn’t anything to do on the Nest side of things.

One other option would be to create your own redis provider connection and more easily close that with proper intellisense. Then when that closes the cache-manager shouldn’t stay open on close. I’ll be happy to discuss that approach in our Discord if you’re interested

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redis client created with CacheManager does not close when ...
When the nest application quits, it doesn't close the redis client. Expected behavior. When app.quit() it should trigger the CacheModule to ...
Read more >
What if Redis Stops Working - How Do I Keep My App Running
The original intent of the reported issue was, that the user wanted to temporarily disable the Redis cache layer while the Redis server...
Read more >
Handling Nest.js app on Redis cache store disconnection
I need to inject the exposed CACHE_MANAGER in the module constructor to get my hands on the client: import { CACHE_MANAGER, Inject }...
Read more >
Client-side caching in Redis
Client -side caching is a technique used to create high performance services. It exploits the memory available on application servers, servers that are...
Read more >
Could not connect to redis connection refused - Fix it easily
The most common reason for the connection refused error is that the Redis-Server is not started. Redis server should be started to use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found