From 07d01a5448e40b67846b0d12bb76539f5bce67ee Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 13 Apr 2017 14:20:19 -0700 Subject: [PATCH] Fix uncaught exception Fixes: https://github.com/feross/webtorrent/issues/1101 --- lib/torrent.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/torrent.js b/lib/torrent.js index 661c30c6..dd49c1df 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -1498,6 +1498,8 @@ Torrent.prototype._request = function (wire, index, hotswap) { var chunkLength = isWebSeed ? piece.chunkLengthRemaining(reservation) : piece.chunkLength(reservation) wire.request(index, chunkOffset, chunkLength, function onChunk (err, chunk) { + if (self.destroyed) return + // TODO: what is this for? if (!self.ready) return self.once('ready', function () { onChunk(err, chunk) })