mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-31 02:21:36 +00:00
Clear reconnect timeout on destroy
This commit is contained in:
parent
35e6eeaef2
commit
3252070328
@ -87,6 +87,7 @@ WebSocketTracker.prototype.destroy = function (cb) {
|
||||
if (self.destroyed) return cb(null)
|
||||
self.destroyed = true
|
||||
clearInterval(self.interval)
|
||||
clearTimeout(self.reconnectTimer)
|
||||
|
||||
if (socketPool[self.announceUrl]) socketPool[self.announceUrl].consumers--
|
||||
|
||||
@ -299,11 +300,11 @@ WebSocketTracker.prototype._startReconnectTimer = function () {
|
||||
var ms = Math.floor(Math.random() * RECONNECT_VARIANCE) + Math.min(Math.pow(2, self.retries) * RECONNECT_MINIMUM, RECONNECT_MAXIMUM)
|
||||
|
||||
self.reconnecting = true
|
||||
var reconnectTimer = setTimeout(function () {
|
||||
self.reconnectTimer = setTimeout(function () {
|
||||
self.retries++
|
||||
self._openSocket()
|
||||
}, ms)
|
||||
if (reconnectTimer.unref) reconnectTimer.unref()
|
||||
if (self.reconnectTimer.unref) self.reconnectTimer.unref()
|
||||
|
||||
debug('reconnecting socket in %s ms', ms)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user