File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -308,7 +308,8 @@ RedisClient.prototype.on_ready = function () {
308
308
}
309
309
} ;
310
310
Object . keys ( this . subscription_set ) . forEach ( function ( key ) {
311
- var parts = key . split ( " " ) ;
311
+ var space_index = key . indexOf ( " " ) ;
312
+ var parts = [ key . slice ( 0 , space_index ) , key . slice ( space_index + 1 ) ] ;
312
313
debug ( "Sending pub/sub on_ready " + parts [ 0 ] + ", " + parts [ 1 ] ) ;
313
314
callback_count ++ ;
314
315
self . send_command ( parts [ 0 ] + "scribe" , [ parts [ 1 ] ] , callback ) ;
Original file line number Diff line number Diff line change @@ -43,14 +43,22 @@ describe("publish/subscribe", function () {
43
43
} ) ;
44
44
45
45
describe ( 'subscribe' , function ( ) {
46
- it ( 'fires a subscribe event for each channel subscribed to' , function ( done ) {
46
+ it ( 'fires a subscribe event for each channel subscribed to even after reconnecting' , function ( done ) {
47
+ var a = false ;
47
48
sub . on ( "subscribe" , function ( chnl , count ) {
48
49
if ( chnl === channel2 ) {
49
50
assert . equal ( 2 , count ) ;
50
- return done ( ) ;
51
+ if ( a ) {
52
+ return done ( ) ;
53
+ }
54
+ sub . stream . destroy ( ) ;
51
55
}
52
56
} ) ;
53
57
58
+ sub . on ( 'reconnecting' , function ( ) {
59
+ a = true ;
60
+ } ) ;
61
+
54
62
sub . subscribe ( channel , channel2 ) ;
55
63
} ) ;
56
64
You can’t perform that action at this time.
0 commit comments