File tree 4 files changed +60
-0
lines changed
4 files changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -331,6 +331,7 @@ class Cluster extends EventEmitter {
331
331
this . setStatus ( "disconnecting" ) ;
332
332
333
333
clearInterval ( this . _addedScriptHashesCleanInterval ) ;
334
+ this . _addedScriptHashesCleanInterval = null ;
334
335
335
336
if ( ! reconnect ) {
336
337
this . manuallyClosing = true ;
@@ -362,6 +363,9 @@ class Cluster extends EventEmitter {
362
363
const status = this . status ;
363
364
this . setStatus ( "disconnecting" ) ;
364
365
366
+ clearInterval ( this . _addedScriptHashesCleanInterval ) ;
367
+ this . _addedScriptHashesCleanInterval = null ;
368
+
365
369
this . manuallyClosing = true ;
366
370
367
371
if ( this . reconnectTimeout ) {
Original file line number Diff line number Diff line change @@ -406,6 +406,7 @@ Redis.prototype.connect = function (callback) {
406
406
*/
407
407
Redis . prototype . disconnect = function ( reconnect ) {
408
408
clearInterval ( this . _addedScriptHashesCleanInterval ) ;
409
+ this . _addedScriptHashesCleanInterval = null ;
409
410
410
411
if ( ! reconnect ) {
411
412
this . manuallyClosing = true ;
@@ -698,6 +699,11 @@ Redis.prototype.sendCommand = function (command, stream) {
698
699
return command . promise ;
699
700
}
700
701
702
+ if ( command . name === "quit" ) {
703
+ clearInterval ( this . _addedScriptHashesCleanInterval ) ;
704
+ this . _addedScriptHashesCleanInterval = null ;
705
+ }
706
+
701
707
let writable =
702
708
this . status === "ready" ||
703
709
( ! stream &&
Original file line number Diff line number Diff line change @@ -411,3 +411,31 @@ describe("cluster:connect", function () {
411
411
} ) ;
412
412
} ) ;
413
413
} ) ;
414
+
415
+ describe ( "cluster:disconnect" , function ( ) {
416
+ it ( "should clear the added script hashes interval when disconnecting" , function ( done ) {
417
+ new MockServer ( 30001 ) ;
418
+ const cluster = new Cluster ( [ { host : "127.0.0.1" , port : "30001" } ] , {
419
+ enableReadyCheck : false ,
420
+ } ) ;
421
+ cluster . once ( "ready" , function ( ) {
422
+ cluster . disconnect ( ) ;
423
+
424
+ expect ( cluster . _addedScriptHashesCleanInterval ) . to . be . null ;
425
+ done ( ) ;
426
+ } ) ;
427
+ } ) ;
428
+
429
+ it ( "should clear the added script hashes interval when quitting" , function ( done ) {
430
+ new MockServer ( 30001 ) ;
431
+ const cluster = new Cluster ( [ { host : "127.0.0.1" , port : "30001" } ] , {
432
+ enableReadyCheck : false ,
433
+ } ) ;
434
+ cluster . once ( "ready" , function ( ) {
435
+ cluster . quit ( ) ;
436
+
437
+ expect ( cluster . _addedScriptHashesCleanInterval ) . to . be . null ;
438
+ done ( ) ;
439
+ } ) ;
440
+ } ) ;
441
+ } ) ;
Original file line number Diff line number Diff line change @@ -475,3 +475,25 @@ describe("connection", function () {
475
475
} ) ;
476
476
} ) ;
477
477
} ) ;
478
+
479
+ describe ( "disconnection" , function ( ) {
480
+ it ( "should clear the added script hashes interval when disconnecting" , function ( done ) {
481
+ const redis = new Redis ( ) ;
482
+ redis . once ( "ready" , function ( ) {
483
+ redis . disconnect ( ) ;
484
+
485
+ expect ( redis . _addedScriptHashesCleanInterval ) . to . be . null ;
486
+ done ( ) ;
487
+ } ) ;
488
+ } ) ;
489
+
490
+ it ( "should clear the added script hashes interval when quitting" , function ( done ) {
491
+ const redis = new Redis ( ) ;
492
+ redis . once ( "ready" , function ( ) {
493
+ redis . quit ( ) ;
494
+
495
+ expect ( redis . _addedScriptHashesCleanInterval ) . to . be . null ;
496
+ done ( ) ;
497
+ } ) ;
498
+ } ) ;
499
+ } ) ;
You can’t perform that action at this time.
0 commit comments