@@ -50,38 +50,30 @@ function RedisClient(stream, options) {
5050 this . options . socket_keepalive = true ;
5151 }
5252 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 ;
5555 this . max_attempts = + options . max_attempts || 0 ;
5656 this . command_queue = new Queue ( ) ; // holds sent commands to de-pipeline them
5757 this . offline_queue = new Queue ( ) ; // holds commands issued but not able to be sent
5858 this . commands_sent = 0 ;
5959 this . connect_timeout = + options . connect_timeout || 86400000 ; // 24 * 60 * 60 * 1000 ms
6060 this . enable_offline_queue = true ;
61- if ( this . options . enable_offline_queue === false ) {
61+ if ( options . enable_offline_queue === false ) {
6262 this . enable_offline_queue = false ;
6363 }
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 ;
6865 this . initialize_retry_vars ( ) ;
6966 this . pub_sub_mode = false ;
7067 this . subscription_set = { } ;
7168 this . monitoring = false ;
7269 this . closing = false ;
7370 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 ;
7872 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
8174 this . old_state = null ;
8275
8376 this . install_stream_listeners ( ) ;
84-
8577 events . EventEmitter . call ( this ) ;
8678}
8779util . inherits ( RedisClient , events . EventEmitter ) ;
@@ -199,6 +191,7 @@ RedisClient.prototype.do_auth = function () {
199191 } else if ( self . auth_callback ) {
200192 self . auth_callback ( err ) ;
201193 self . auth_callback = null ;
194+ return ;
202195 } else {
203196 self . emit ( "error" , err ) ;
204197 return ;
@@ -928,10 +921,12 @@ RedisClient.prototype.auth = RedisClient.prototype.AUTH = function (pass, callba
928921 return ;
929922 }
930923 this . auth_pass = pass ;
931- this . auth_callback = callback ;
932924 debug ( "Saving auth as " + this . auth_pass ) ;
925+ // Only run the callback once. So do not safe it if already connected
933926 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 ;
935930 }
936931} ;
937932
0 commit comments