Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2020-10-27 07:54:12 +0300
committerFeross Aboukhadijeh <feross@feross.org>2020-10-27 07:54:12 +0300
commitc7297e9859c9b2413f3f00d07ab4ab8e95693647 (patch)
treebaae8eaaa37162e9238dc62242e5d1ef22b096c7 /lib
parent5a668ccacfc6f055f50da300a1206eff69752d51 (diff)
Fix "Cannot read property 'utp' of null"
Fixes #1940
Diffstat (limited to 'lib')
-rw-r--r--lib/torrent.js7
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()
})
}