Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unavailable Redis connection kills Nodejs process (crashes the server) #38

Open
danBamikiya opened this issue Aug 18, 2021 · 0 comments · May be fixed by #40
Open

Unavailable Redis connection kills Nodejs process (crashes the server) #38

danBamikiya opened this issue Aug 18, 2021 · 0 comments · May be fixed by #40
Assignees
Labels
enhancement New feature or request product Changes to the product

Comments

@danBamikiya
Copy link
Owner

Currently if the Redis server isn't available, the redis client throws an error and since this error is unhandled, it crashes the Nodejs server.

This is by design (a good thing) since the Redis store is used as the primary storage for shortened urls. So if the Redis server isn't available, the app can't work.
But when introducing a database, we'll want to avoid those crashes (handle the errors) since the database will now be the primary storage and the Redis store will be just a caching layer.

The current error logger has Sentry an application monitoring and error tracking software integrated into it so the error handler can log the errors as level error which is an high enough level to notify me.
Meanwhile a retry strategy could be implemented to retry establishing connections with the Redis server.

Also on redis client connection to the Redis server, the Redis server should be pinged periodically to prevent an idle connection timeout from closing the connection. The connection timeout is by default 1 hour.

danBamikiya added a commit that referenced this issue Aug 18, 2021
Since we're going to setup a database as a primary data persistence, Redis won't be needed a primary memory store but just as a caching layer. So all redis connection errors are handled to prevent the errors from crashing the Nodejs server

* configure a retry strategy for redis client when connection to Redis server is unavailable
* ping Redis server every 60 minutes to prevent an idle connection timeout
* add event listeners to redis client for basic logging
* set log level to emergency on Nodejs server crashes
* add redis client names for Nodejs connection to Redis server and rate-limit store connection to Redis server
* format Redis connection errors to be more verbose and readable

Resolves #38
@danBamikiya danBamikiya self-assigned this Aug 18, 2021
@danBamikiya danBamikiya added product Changes to the product enhancement New feature or request labels Aug 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request product Changes to the product
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant