Skip to content

Commit da50364

Browse files
committed
fix exception in websocket tracker
1 parent fdb94e9 commit da50364

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

lib/http-tracker.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ function HTTPTracker (client, announceUrl, opts) {
4444

4545
HTTPTracker.prototype.announce = function (opts) {
4646
var self = this
47+
if (self.destroyed) return
4748
if (self._trackerId) opts.trackerid = self._trackerId
4849

4950
if (opts.compact == null) opts.compact = 1
@@ -58,6 +59,7 @@ HTTPTracker.prototype.announce = function (opts) {
5859

5960
HTTPTracker.prototype.scrape = function (opts) {
6061
var self = this
62+
if (self.destroyed) return
6163

6264
if (!self._scrapeUrl) {
6365
self.client.emit('error', new Error('scrape not supported ' + self._announceUrl))

lib/udp-tracker.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ function UDPTracker (client, announceUrl, opts) {
3939

4040
UDPTracker.prototype.announce = function (opts) {
4141
var self = this
42+
if (self.destroyed) return
4243
self._request(opts)
4344
}
4445

4546
UDPTracker.prototype.scrape = function (opts) {
4647
var self = this
48+
if (self.destroyed) return
4749
opts._scrape = true
4850
self._request(opts) // udp scrape uses same announce url
4951
}

lib/websocket-tracker.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ function WebSocketTracker (client, announceUrl, opts) {
4646

4747
WebSocketTracker.prototype.announce = function (opts) {
4848
var self = this
49+
if (self.destroyed) return
4950
if (!self._socket.connected) {
5051
return self._socket.once('connect', self.announce.bind(self, opts))
5152
}
@@ -69,6 +70,7 @@ WebSocketTracker.prototype.announce = function (opts) {
6970

7071
WebSocketTracker.prototype.scrape = function (opts) {
7172
var self = this
73+
if (self.destroyed) return
7274
self._onSocketError(new Error('scrape not supported ' + self._announceUrl))
7375
}
7476

0 commit comments

Comments
 (0)