@@ -152,27 +152,15 @@ RedisClient.prototype.flush_and_error = function (message) {
152
152
while ( this . offline_queue . length > 0 ) {
153
153
command_obj = this . offline_queue . shift ( ) ;
154
154
if ( typeof command_obj . callback === "function" ) {
155
- try {
156
- command_obj . callback ( error ) ;
157
- } catch ( callback_err ) {
158
- process . nextTick ( function ( ) {
159
- throw callback_err ;
160
- } ) ;
161
- }
155
+ command_obj . callback ( error ) ;
162
156
}
163
157
}
164
158
this . offline_queue = new Queue ( ) ;
165
159
166
160
while ( this . command_queue . length > 0 ) {
167
161
command_obj = this . command_queue . shift ( ) ;
168
162
if ( typeof command_obj . callback === "function" ) {
169
- try {
170
- command_obj . callback ( error ) ;
171
- } catch ( callback_err ) {
172
- process . nextTick ( function ( ) {
173
- throw callback_err ;
174
- } ) ;
175
- }
163
+ command_obj . callback ( error ) ;
176
164
}
177
165
}
178
166
this . command_queue = new Queue ( ) ;
@@ -529,38 +517,13 @@ RedisClient.prototype.return_error = function (err) {
529
517
this . emit ( "drain" ) ;
530
518
this . should_buffer = false ;
531
519
}
532
-
533
- try {
520
+ if ( command_obj . callback ) {
534
521
command_obj . callback ( err ) ;
535
- } catch ( callback_err ) {
536
- // if a callback throws an exception, re-throw it on a new stack so the parser can keep going
537
- process . nextTick ( function ( ) {
538
- throw callback_err ;
539
- } ) ;
522
+ } else {
523
+ this . emit ( 'error' , err ) ;
540
524
}
541
525
} ;
542
526
543
- // if a callback throws an exception, re-throw it on a new stack so the parser can keep going.
544
- // if a domain is active, emit the error on the domain, which will serve the same function.
545
- // put this try/catch in its own function because V8 doesn't optimize this well yet.
546
- function try_callback ( callback , reply ) {
547
- try {
548
- callback ( null , reply ) ;
549
- } catch ( err ) {
550
- if ( process . domain ) {
551
- var currDomain = process . domain ;
552
- currDomain . emit ( 'error' , err ) ;
553
- if ( process . domain === currDomain ) {
554
- currDomain . exit ( ) ;
555
- }
556
- } else {
557
- process . nextTick ( function ( ) {
558
- throw err ;
559
- } ) ;
560
- }
561
- }
562
- }
563
-
564
527
// hgetall converts its replies to an Object. If the reply is empty, null is returned.
565
528
function reply_to_object ( reply ) {
566
529
var obj = { } , j , jl , key , val ;
@@ -638,7 +601,7 @@ RedisClient.prototype.return_reply = function (reply) {
638
601
reply = reply_to_object ( reply ) ;
639
602
}
640
603
641
- try_callback ( command_obj . callback , reply ) ;
604
+ command_obj . callback ( null , reply ) ;
642
605
} else {
643
606
debug ( "no callback for reply: " + ( reply && reply . toString && reply . toString ( ) ) ) ;
644
607
}
@@ -662,7 +625,7 @@ RedisClient.prototype.return_reply = function (reply) {
662
625
// reply[1] can be null
663
626
var reply1String = ( reply [ 1 ] === null ) ? null : reply [ 1 ] . toString ( ) ;
664
627
if ( command_obj && typeof command_obj . callback === "function" ) {
665
- try_callback ( command_obj . callback , reply1String ) ;
628
+ command_obj . callback ( null , reply1String ) ;
666
629
}
667
630
this . emit ( type , reply1String , reply [ 2 ] ) ; // channel, count
668
631
} else {
0 commit comments