@@ -50,38 +50,30 @@ function RedisClient(stream, options) {
50
50
this . options . socket_keepalive = true ;
51
51
}
52
52
this . should_buffer = false ;
53
- this . command_queue_high_water = this . options . command_queue_high_water || 1000 ;
54
- this . command_queue_low_water = this . options . command_queue_low_water || 0 ;
53
+ this . command_queue_high_water = options . command_queue_high_water || 1000 ;
54
+ this . command_queue_low_water = options . command_queue_low_water || 0 ;
55
55
this . max_attempts = + options . max_attempts || 0 ;
56
56
this . command_queue = new Queue ( ) ; // holds sent commands to de-pipeline them
57
57
this . offline_queue = new Queue ( ) ; // holds commands issued but not able to be sent
58
58
this . commands_sent = 0 ;
59
59
this . connect_timeout = + options . connect_timeout || 86400000 ; // 24 * 60 * 60 * 1000 ms
60
60
this . enable_offline_queue = true ;
61
- if ( this . options . enable_offline_queue === false ) {
61
+ if ( options . enable_offline_queue === false ) {
62
62
this . enable_offline_queue = false ;
63
63
}
64
- this . retry_max_delay = null ;
65
- if ( options . retry_max_delay && options . retry_max_delay > 0 ) {
66
- this . retry_max_delay = + options . retry_max_delay ;
67
- }
64
+ this . retry_max_delay = + options . retry_max_delay || null ;
68
65
this . initialize_retry_vars ( ) ;
69
66
this . pub_sub_mode = false ;
70
67
this . subscription_set = { } ;
71
68
this . monitoring = false ;
72
69
this . closing = false ;
73
70
this . server_info = { } ;
74
- this . auth_pass = null ;
75
- if ( options . auth_pass !== undefined ) {
76
- this . auth_pass = options . auth_pass ;
77
- }
71
+ this . auth_pass = options . auth_pass ;
78
72
this . parser_module = null ;
79
- this . selected_db = null ; // save the selected db here, used when reconnecting
80
-
73
+ this . selected_db = null ; // save the selected db here, used when reconnecting
81
74
this . old_state = null ;
82
75
83
76
this . install_stream_listeners ( ) ;
84
-
85
77
events . EventEmitter . call ( this ) ;
86
78
}
87
79
util . inherits ( RedisClient , events . EventEmitter ) ;
@@ -199,6 +191,7 @@ RedisClient.prototype.do_auth = function () {
199
191
} else if ( self . auth_callback ) {
200
192
self . auth_callback ( err ) ;
201
193
self . auth_callback = null ;
194
+ return ;
202
195
} else {
203
196
self . emit ( "error" , err ) ;
204
197
return ;
@@ -928,10 +921,12 @@ RedisClient.prototype.auth = RedisClient.prototype.AUTH = function (pass, callba
928
921
return ;
929
922
}
930
923
this . auth_pass = pass ;
931
- this . auth_callback = callback ;
932
924
debug ( "Saving auth as " + this . auth_pass ) ;
925
+ // Only run the callback once. So do not safe it if already connected
933
926
if ( this . connected ) {
934
- this . send_command ( "auth" , pass , callback ) ;
927
+ this . send_command ( "auth" , [ this . auth_pass ] , callback ) ;
928
+ } else {
929
+ this . auth_callback = callback ;
935
930
}
936
931
} ;
937
932
0 commit comments