@@ -79,6 +79,8 @@ var PromiseContainer = require('./promiseContainer');
79
79
* @param {string } [options.keyPrefix=''] - The prefix to prepend to all keys in a command.
80
80
* @param {function } [options.retryStrategy] - See "Quick Start" section
81
81
* @param {number } [options.maxRetriesPerRequest] - See "Quick Start" section
82
+ * @param {number } [options.maxLoadingRetryTime=10000] - when redis server is not ready, we will wait for
83
+ * `loading_eta_seconds` from `info` command or maxLoadingRetryTime (milliseconds), whichever is smaller.
82
84
* @param {function } [options.reconnectOnError] - See "Quick Start" section
83
85
* @param {boolean } [options.readOnly=false] - Enable READONLY mode for the connection.
84
86
* Only available for cluster mode.
@@ -185,7 +187,8 @@ Redis.defaultOptions = {
185
187
reconnectOnError : null ,
186
188
readOnly : false ,
187
189
stringNumbers : false ,
188
- maxRetriesPerRequest : 20
190
+ maxRetriesPerRequest : 20 ,
191
+ maxLoadingRetryTime : 10000
189
192
} ;
190
193
191
194
Redis . prototype . resetCommandQueue = function ( ) {
@@ -451,7 +454,10 @@ Redis.prototype._readyCheck = function (callback) {
451
454
if ( ! info . loading || info . loading === '0' ) {
452
455
callback ( null , info ) ;
453
456
} else {
454
- var retryTime = ( info . loading_eta_seconds || 1 ) * 1000 ;
457
+ var loadingEtaMs = ( info . loading_eta_seconds || 1 ) * 1000 ;
458
+ var retryTime = _this . options . maxLoadingRetryTime && _this . options . maxLoadingRetryTime < loadingEtaMs
459
+ ? _this . options . maxLoadingRetryTime
460
+ : loadingEtaMs
455
461
debug ( 'Redis server still loading, trying again in ' + retryTime + 'ms' ) ;
456
462
setTimeout ( function ( ) {
457
463
_this . _readyCheck ( callback ) ;
0 commit comments