RetryStrategy not taking effect in cluster mode
Author: hheshamazonCreated Sep 21, 2022Updated Aug 25, 2026
Labelsstale
Hello,
I attempted to setup a redis cluster client with exponential back off enabled but failed.
After some deep dive, I found the root cause to be that is the connection pool overrides the retryStrategy option I explicitly set in the redisOptions.
I used the following snippet to connect to the cluster.
const ioredis = require("ioredis")
cluster = new ioredis.Cluster([
{
host: "<redacted>",
port: 6379,
}
], {
dnsLookup: (address, callback) => callback(null, address),
redisOptions: {
tls: {},
retryStrategy: function (times) {
return times;
},
username:"<redacted>",
password:"<redacted>"
}
})but then I get ioredis:connection skip reconnecting because retryStrategy is not a function +0ms in the debug logs.
I was able to reliably confirm that the option is overridden by the connection pool.
The reconnection would happen at the next slot refresh cycle which has a constant cadence, so my attempt to set up exponential back off on disconnection fails.
Questions :
- Is this intentional behavior ?
- What is the recommended way to set up exponential back off retry strategy on a cluster client ? (If supported)
- Should the client documentation be updated to indicate that this option is ignored for cluster clients ? or better yet an assertion can be implemented to get the issue to pop up in the development stage rather in production stages.
Thanks, Hesham
Source: redis/ioredis