Skip to content
This repository was archived by the owner on Sep 30, 2023. It is now read-only.

Commit e4512b3

Browse files
authored
Merge pull request #29 from wouldgo/replicator-clear-set-interval
Replicator _flushTimers clearing
2 parents 5175c01 + 8857b64 commit e4512b3

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/Replicator.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ class Replicator extends EventEmitter {
107107
}
108108
}
109109

110+
stop() {
111+
//Clears the queue flusher
112+
clearInterval(this._flushTimer)
113+
}
114+
110115
_addToQueue (entry) {
111116
const hash = entry.hash || entry
112117

src/Store.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ class Store {
150150
if (this.options.onClose)
151151
await this.options.onClose(this.address.toString())
152152

153+
//Replicator teardown logic
154+
this._replicator.stop();
155+
153156
// Reset replication statistics
154157
this._replicationStatus.reset()
155158

@@ -438,7 +441,7 @@ class Store {
438441

439442
_recalculateReplicationProgress (max) {
440443
this._replicationStatus.progress = Math.max.apply(null, [
441-
this._replicationStatus.progress,
444+
this._replicationStatus.progress,
442445
this._oplog.length,
443446
max || 0,
444447
])
@@ -447,8 +450,8 @@ class Store {
447450

448451
_recalculateReplicationMax (max) {
449452
this._replicationStatus.max = Math.max.apply(null, [
450-
this._replicationStatus.max,
451-
this._oplog.length,
453+
this._replicationStatus.max,
454+
this._oplog.length,
452455
max || 0,
453456
])
454457
}

0 commit comments

Comments
 (0)