WIP - fix #2141 - cluster redirect if client closed #2701
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Here is a rough attempt to resolve issues described in #2141 (I'm not an expert with TS and would like someone to take over this PR)
createCluster
is currently unable to update slots when slots are out of date (when a master node goes down and a replica takes over)This causes the client to throw
ClientClosedError
forever until the application is restarted.This PR takes inspiration from https://github.com/redis/go-redis
Related: #2141 (comment)
Known issues
Do not use
isolated
-commandOptions
; this breaks the client forever, the duplicated client from using this command option would keep using old node addresses and causeConnection timeout
on each reconnection. This PR attempts to make changes only to the cluster client and won't make any fixes to this issue (this issue already exists prior this PR)e.g.
Try it out
For those interested in trying this client out you can install it using the following:
It is available here: https://www.npmjs.com/package/@scorpionknifes/redis-client
Reminder - this is a draft and don't use this for production.
Testing
I've tested this against docker, k8s
Writing tests for these is almost impossible cause it relies on simulating a Redis master going down. (aka no tests written for these)
Checklist
npm test
pass with this change (including linting)?