@@ -677,10 +677,11 @@ RedisClient.prototype.send_command = function (command, args, callback) {
677
677
err = new Error ( 'send_command: ' + command + ' value must not be undefined or null' ) ;
678
678
err . command = command ;
679
679
if ( callback ) {
680
- return callback && callback ( err ) ;
680
+ callback ( err ) ;
681
+ } else {
682
+ this . emit ( 'error' , err ) ;
681
683
}
682
- this . emit ( 'error' , err ) ;
683
- return ;
684
+ return false ;
684
685
}
685
686
}
686
687
@@ -715,7 +716,8 @@ RedisClient.prototype.send_command = function (command, args, callback) {
715
716
this . offline_queue . push ( command_obj ) ;
716
717
this . should_buffer = true ;
717
718
}
718
- return ;
719
+ // Return false to signal no buffering
720
+ return false ;
719
721
}
720
722
721
723
if ( command === 'subscribe' || command === 'psubscribe' || command === 'unsubscribe' || command === 'punsubscribe' ) {
@@ -728,7 +730,7 @@ RedisClient.prototype.send_command = function (command, args, callback) {
728
730
err = new Error ( 'Connection in subscriber mode, only subscriber commands may be used' ) ;
729
731
err . command = command . toUpperCase ( ) ;
730
732
this . emit ( 'error' , err ) ;
731
- return ;
733
+ return false ;
732
734
}
733
735
this . command_queue . push ( command_obj ) ;
734
736
this . commands_sent += 1 ;
@@ -916,8 +918,7 @@ commands.forEach(function (fullCommand) {
916
918
// store db in this.select_db to restore it on reconnect
917
919
RedisClient . prototype . select = RedisClient . prototype . SELECT = function ( db , callback ) {
918
920
var self = this ;
919
-
920
- this . send_command ( 'select' , [ db ] , function ( err , res ) {
921
+ return this . send_command ( 'select' , [ db ] , function ( err , res ) {
921
922
if ( err === null ) {
922
923
self . selected_db = db ;
923
924
}
@@ -939,16 +940,16 @@ RedisClient.prototype.auth = RedisClient.prototype.AUTH = function (pass, callba
939
940
} else {
940
941
this . emit ( 'error' , err ) ;
941
942
}
942
- return ;
943
+ return false ;
943
944
}
944
945
this . auth_pass = pass ;
945
946
debug ( 'Saving auth as ' + this . auth_pass ) ;
946
947
// Only run the callback once. So do not safe it if already connected
947
948
if ( this . connected ) {
948
- this . send_command ( 'auth' , [ this . auth_pass ] , callback ) ;
949
- } else {
950
- this . auth_callback = callback ;
949
+ return this . send_command ( 'auth' , [ this . auth_pass ] , callback ) ;
951
950
}
951
+ this . auth_callback = callback ;
952
+ return false ;
952
953
} ;
953
954
954
955
RedisClient . prototype . hmset = RedisClient . prototype . HMSET = function ( key , args , callback ) {
@@ -1048,7 +1049,7 @@ Multi.prototype.exec = Multi.prototype.EXEC = function (callback) {
1048
1049
this . send_command ( command , args , index , cb ) ;
1049
1050
}
1050
1051
1051
- this . _client . send_command ( 'exec' , [ ] , function ( err , replies ) {
1052
+ return this . _client . send_command ( 'exec' , [ ] , function ( err , replies ) {
1052
1053
self . execute_callback ( err , replies ) ;
1053
1054
} ) ;
1054
1055
} ;
0 commit comments