diff --git a/lib/http-tracker.js b/lib/http-tracker.js index a8396a7..665a2af 100644 --- a/lib/http-tracker.js +++ b/lib/http-tracker.js @@ -26,6 +26,7 @@ function HTTPTracker (client, announceUrl, opts) { debug('new http tracker %s', announceUrl) self.client = client + self.destroyed = false self._opts = opts self._announceUrl = announceUrl diff --git a/lib/udp-tracker.js b/lib/udp-tracker.js index 1739988..2b4dc12 100644 --- a/lib/udp-tracker.js +++ b/lib/udp-tracker.js @@ -28,6 +28,7 @@ function UDPTracker (client, announceUrl, opts) { debug('new udp tracker %s', announceUrl) self.client = client + self.destroyed = false self._opts = opts self._announceUrl = announceUrl @@ -95,10 +96,8 @@ UDPTracker.prototype._request = function (opts) { var ms = opts.event === 'stopped' ? TIMEOUT / 10 : TIMEOUT var timeout = setTimeout(function () { timeout = null - cleanup() - if (opts.event !== 'stopped') { - onError(new Error('tracker request timed out')) - } + if (opts.event === 'stopped') cleanup() + else onError(new Error('tracker request timed out (' + opts.event + ')')) }, ms) if (timeout.unref) timeout.unref() diff --git a/lib/websocket-tracker.js b/lib/websocket-tracker.js index bb1bc38..3a88959 100644 --- a/lib/websocket-tracker.js +++ b/lib/websocket-tracker.js @@ -22,6 +22,7 @@ function WebSocketTracker (client, announceUrl, opts) { debug('new websocket tracker %s', announceUrl) self.client = client + self.destroyed = false self._opts = opts self._announceUrl = announceUrl