Skip to content

Commit 6df64ff

Browse files
committed
Fixes for PR webtorrent#126
1 parent 2fee125 commit 6df64ff

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

lib/client/http-tracker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ HTTPTracker.prototype.scrape = function (opts) {
7474

7575
HTTPTracker.prototype.destroy = function (cb) {
7676
var self = this
77-
if (self.destroyed) return cb && cb()
77+
if (self.destroyed) return cb(null)
7878
self.destroyed = true
7979
clearInterval(self.interval)
8080

lib/client/udp-tracker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ UDPTracker.prototype.scrape = function (opts) {
4747

4848
UDPTracker.prototype.destroy = function (cb) {
4949
var self = this
50-
if (self.destroyed) return cb && cb()
50+
if (self.destroyed) return cb(null)
5151
self.destroyed = true
5252
clearInterval(self.interval)
5353

lib/client/websocket-tracker.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ WebSocketTracker.prototype.scrape = function (opts) {
6464
self._onSocketError(new Error('scrape not supported ' + self.announceUrl))
6565
}
6666

67-
WebSocketTracker.prototype.destroy = function (onclose) {
67+
WebSocketTracker.prototype.destroy = function (cb) {
6868
var self = this
69-
if (self.destroyed) return onclose && onclose()
69+
if (!cb) cb = noop
70+
if (self.destroyed) return cb(null)
7071
self.destroyed = true
7172
clearInterval(self.interval)
7273

@@ -84,9 +85,9 @@ WebSocketTracker.prototype.destroy = function (onclose) {
8485

8586
self.socket.on('error', noop) // ignore all future errors
8687
try {
87-
self.socket.destroy(onclose)
88+
self.socket.destroy(cb)
8889
} catch (err) {
89-
if (onclose) onclose()
90+
cb(null)
9091
}
9192

9293
self.socket = null

0 commit comments

Comments
 (0)