@@ -193,7 +193,13 @@ RedisClient.prototype.on_error = function (msg) {
193
193
this . connected = false ;
194
194
this . ready = false ;
195
195
196
- this . emit ( "error" , new Error ( message ) ) ;
196
+ try {
197
+ this . emit ( "error" , new Error ( message ) ) ;
198
+ } catch ( error ) {
199
+ this . flush_and_error ( message ) ;
200
+ throw error ;
201
+ }
202
+
197
203
// "error" events get turned into exceptions if they aren't listened for. If the user handled this error
198
204
// then we should try to reconnect.
199
205
this . connection_gone ( "error" ) ;
@@ -483,11 +489,10 @@ RedisClient.prototype.connection_gone = function (why) {
483
489
this . emitted_end = true ;
484
490
}
485
491
486
- this . flush_and_error ( "Redis connection gone from " + why + " event." ) ;
487
-
488
492
// If this is a requested shutdown, then don't retry
489
493
if ( this . closing ) {
490
494
this . retry_timer = null ;
495
+ this . flush_and_error ( "Redis connection gone from " + why + " event." ) ;
491
496
if ( exports . debug_mode ) {
492
497
console . warn ( "connection ended from quit command, not retrying." ) ;
493
498
}
@@ -507,6 +512,7 @@ RedisClient.prototype.connection_gone = function (why) {
507
512
508
513
if ( this . max_attempts && this . attempts >= this . max_attempts ) {
509
514
this . retry_timer = null ;
515
+ this . flush_and_error ( "Redis connection gone from " + why + " event." ) ;
510
516
// TODO - some people need a "Redis is Broken mode" for future commands that errors immediately, and others
511
517
// want the program to exit. Right now, we just log, which doesn't really help in either case.
512
518
console . error ( "node_redis: Couldn't get Redis connection after " + this . max_attempts + " attempts." ) ;
0 commit comments