@@ -4,6 +4,7 @@ var utils = require('./utils');
4
4
var debug = require ( './debug' ) ;
5
5
var Multi = require ( './multi' ) ;
6
6
var no_password_is_set = / n o p a s s w o r d i s s e t / ;
7
+ var loading = / L O A D I N G / ;
7
8
var RedisClient = require ( '../' ) . RedisClient ;
8
9
9
10
/********************************
@@ -36,14 +37,14 @@ RedisClient.prototype.select = RedisClient.prototype.SELECT = function select (d
36
37
RedisClient . prototype . info = RedisClient . prototype . INFO = function info ( section , callback ) {
37
38
var self = this ;
38
39
var ready = this . ready ;
40
+ var args = [ ] ;
39
41
if ( typeof section === 'function' ) {
40
42
callback = section ;
41
- section = 'default' ;
42
- } else if ( section === undefined ) {
43
- section = 'default' ;
43
+ } else if ( section !== undefined ) {
44
+ args = Array . isArray ( section ) ? section : [ section ] ;
44
45
}
45
46
this . ready = ready || this . offline_queue . length === 0 ; // keep the execution order intakt
46
- var tmp = this . send_command ( 'info' , [ section ] , function ( err , res ) {
47
+ var tmp = this . send_command ( 'info' , args , function ( err , res ) {
47
48
if ( res ) {
48
49
var obj = { } ;
49
50
var lines = res . toString ( ) . split ( '\r\n' ) ;
@@ -91,12 +92,20 @@ RedisClient.prototype.auth = RedisClient.prototype.AUTH = function auth (pass, c
91
92
this . auth_pass = pass ;
92
93
this . ready = this . offline_queue . length === 0 ; // keep the execution order intakt
93
94
var tmp = this . send_command ( 'auth' , [ pass ] , function ( err , res ) {
94
- if ( err && no_password_is_set . test ( err . message ) ) {
95
- self . warn ( 'Warning: Redis server does not require a password, but a password was supplied.' ) ;
96
- err = null ;
97
- res = 'OK' ;
95
+ if ( err ) {
96
+ if ( no_password_is_set . test ( err . message ) ) {
97
+ self . warn ( 'Warning: Redis server does not require a password, but a password was supplied.' ) ;
98
+ err = null ;
99
+ res = 'OK' ;
100
+ } else if ( loading . test ( err . message ) ) {
101
+ // If redis is still loading the db, it will not authenticate and everything else will fail
102
+ debug ( 'Redis still loading, trying to authenticate later' ) ;
103
+ setTimeout ( function ( ) {
104
+ self . auth ( pass , callback ) ;
105
+ } , 200 ) ;
106
+ return ;
107
+ }
98
108
}
99
-
100
109
utils . callback_or_emit ( self , callback , err , res ) ;
101
110
} ) ;
102
111
this . ready = ready ;
0 commit comments