diff --git a/lib/db.js b/lib/db.js index 674fbf0..6387f20 100644 --- a/lib/db.js +++ b/lib/db.js @@ -36,7 +36,13 @@ class LimitDBRedis extends EventEmitter { enableOfflineQueue: false, keyPrefix: config.prefix, password: config.password, - tls: config.tls + tls: config.tls, + reconnectOnError: (err) => { + // will force a reconnect when error starts with `READONLY` + // this code is only triggered when auto-failover is disabled + // more: https://github.com/luin/ioredis#reconnect-on-error + return err.message.includes('READONLY'); + }, }; const clusterOptions = { @@ -325,7 +331,7 @@ class LimitDBRedis extends EventEmitter { }, callback); } - _determineCount({paramsCount, defaultCount, bucketKeyConfigSize}) { + _determineCount({ paramsCount, defaultCount, bucketKeyConfigSize }) { if (paramsCount === 'all') { return bucketKeyConfigSize; } diff --git a/package.json b/package.json index e40fe3a..e23ff93 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "dependencies": { "async": "^2.6.1", "disyuntor": "^3.5.0", - "ioredis": "^4.5.1", + "ioredis": "^4.28.5", "lodash": "^4.17.15", "lru-cache": "^4.1.5", "ms": "^2.1.2",