diff options
author | Jean-Philippe ALLEGRO <jipai13@gmail.com> | 2020-10-05 00:22:54 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-05 00:22:54 +0300 |
commit | f83f370e541807cedacfc0e93dbff08cadb4a18a (patch) | |
tree | 484bf26d532d80bdb2cd4c3f94ba28d0cc2abc29 /lib | |
parent | 7aee819796c540df0b247fec1853098f9a591d4c (diff) |
check if torrent is destroyed before emitting download/upload event
closes https://github.com/webtorrent/webtorrent/issues/1924
Diffstat (limited to 'lib')
-rw-r--r-- | lib/torrent.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/torrent.js b/lib/torrent.js index caa6687..0fb0145 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -921,7 +921,7 @@ class Torrent extends EventEmitter { this._downloadSpeed(downloaded) this.client._downloadSpeed(downloaded) this.emit('download', downloaded) - this.client.emit('download', downloaded) + if (this.client) this.client.emit('download', downloaded) }) wire.on('upload', uploaded => { @@ -930,7 +930,7 @@ class Torrent extends EventEmitter { this._uploadSpeed(uploaded) this.client._uploadSpeed(uploaded) this.emit('upload', uploaded) - this.client.emit('upload', uploaded) + if (this.client) this.client.emit('upload', uploaded) }) this.wires.push(wire) |