diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2020-10-27 07:54:12 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2020-10-27 07:54:12 +0300 |
commit | c7297e9859c9b2413f3f00d07ab4ab8e95693647 (patch) | |
tree | baae8eaaa37162e9238dc62242e5d1ef22b096c7 /lib | |
parent | 5a668ccacfc6f055f50da300a1206eff69752d51 (diff) |
Fix "Cannot read property 'utp' of null"
Fixes #1940
Diffstat (limited to 'lib')
-rw-r--r-- | lib/torrent.js | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/torrent.js b/lib/torrent.js index ea4e407..89daa38 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -86,7 +86,6 @@ class Torrent extends EventEmitter { this._rechokeOptimisticWire = null this._rechokeOptimisticTime = 0 this._rechokeIntervalId = null - this._reconnectTimeoutId = null this.ready = false this.destroyed = false @@ -658,7 +657,6 @@ class Torrent extends EventEmitter { this.client._remove(this) clearInterval(this._rechokeIntervalId) - clearTimeout(this._reconnectTimeoutId) this._xsRequests.forEach(req => { req.abort() @@ -1729,11 +1727,12 @@ class Torrent extends EventEmitter { peer.addr, ms, peer.retries + 1 ) - this._reconnectTimeoutId = setTimeout(() => { + const reconnectTimeout = setTimeout(() => { + if (this.destroyed) return const newPeer = this._addPeer(peer.addr, this.client.utp ? 'utp' : 'tcp') if (newPeer) newPeer.retries = peer.retries + 1 }, ms) - if (this._reconnectTimeoutId.unref) this._reconnectTimeoutId.unref() + if (reconnectTimeout.unref) reconnectTimeout.unref() }) } |