File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed
Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -31,8 +31,15 @@ KeyValueMemoryConnector.prototype._setupRegularCleanup = function() {
3131 // key expiration too, the scheduled cleanup is merely a performance
3232 // optimization.
3333 var self = this ;
34- this . _cleanupTimer = setInterval (
35- function ( ) { self . _removeExpiredItems ( ) ; } ,
34+ var timer = this . _cleanupTimer = setInterval (
35+ function ( ) {
36+ if ( self && self . _removeExpiredItems ) {
37+ self . _removeExpiredItems ( ) ;
38+ } else {
39+ // The datasource/connector was destroyed - cancel the timer
40+ clearInterval ( timer ) ;
41+ }
42+ } ,
3643 1000 ) ;
3744 this . _cleanupTimer . unref ( ) ;
3845} ;
Original file line number Diff line number Diff line change @@ -2,15 +2,9 @@ var kvMemory = require('../lib/connectors/kv-memory');
22var DataSource = require ( '..' ) . DataSource ;
33
44describe ( 'KeyValue-Memory connector' , function ( ) {
5- var lastDataSource ;
65 var dataSourceFactory = function ( ) {
7- lastDataSource = new DataSource ( { connector : kvMemory } ) ;
8- return lastDataSource ;
6+ return new DataSource ( { connector : kvMemory } ) ;
97 } ;
108
11- afterEach ( function disconnectKVMemoryConnector ( ) {
12- if ( lastDataSource ) return lastDataSource . disconnect ( ) ;
13- } ) ;
14-
159 require ( './kvao.suite' ) ( dataSourceFactory ) ;
1610} ) ;
You can’t perform that action at this time.
0 commit comments