File tree Expand file tree Collapse file tree 3 files changed +7
-6
lines changed
Expand file tree Collapse file tree 3 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ HTTPTracker.prototype.scrape = function (opts) {
7474
7575HTTPTracker . 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
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ UDPTracker.prototype.scrape = function (opts) {
4747
4848UDPTracker . 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments