diff --git a/lib/services/bitcoind.js b/lib/services/bitcoind.js index 2d1f84ab..9d59f48d 100644 --- a/lib/services/bitcoind.js +++ b/lib/services/bitcoind.js @@ -470,12 +470,15 @@ Bitcoin.prototype._checkSyncedAndSubscribeZmqEvents = function(node) { } if (!synced) { interval = setInterval(function() { + if (self.node.stopping) { + return clearInterval(interval); + } checkAndSubscribe(function(err) { if (err) { log.error(err); } }); - }, node._tipUpdateInterval || Bitcoin.DEFAULT_TIP_UPDATE_INTERVAL).unref(); + }, node._tipUpdateInterval || Bitcoin.DEFAULT_TIP_UPDATE_INTERVAL); } }); diff --git a/test/services/bitcoind.unit.js b/test/services/bitcoind.unit.js index f7a228f9..62131046 100644 --- a/test/services/bitcoind.unit.js +++ b/test/services/bitcoind.unit.js @@ -720,7 +720,7 @@ describe('Bitcoin Service', function() { bitcoind._updateTip.callCount.should.equal(10); bitcoind._subscribeZmqEvents.callCount.should.equal(1); done(); - }, 20); + }, 40); }); });