From a69ee078714ebc0d31a6465484ed8bef6b53facb Mon Sep 17 00:00:00 2001 From: fisch0920 Date: Mon, 12 May 2014 01:14:24 -0400 Subject: [PATCH 1/2] added slightly better error logging --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index fe3da18..dfc44cb 100644 --- a/index.js +++ b/index.js @@ -150,7 +150,7 @@ Tracker.prototype._requestHttp = function (requestUrl, opts) { var data = '' if (res.statusCode !== 200) { res.resume() // consume the whole stream - self.client.emit('error', new Error('Invalid response code ' + res.statusCode + ' from tracker')) + self.client.emit('error', new Error('Invalid response code ' + res.statusCode + ' from tracker ' + requestUrl)) return } res.on('data', function (chunk) { @@ -181,7 +181,7 @@ Tracker.prototype._requestUdp = function (requestUrl, opts) { } function error (message) { - self.client.emit('error', new Error(message)) + self.client.emit('error', new Error(message + ' (connecting to tracker ' + requestUrl + ')')) socket.close() clearTimeout(timeout) } From c4684c8b72de56c5b4c475443ec92eee72b0d57b Mon Sep 17 00:00:00 2001 From: fisch0920 Date: Thu, 15 May 2014 06:29:47 -0400 Subject: [PATCH 2/2] fixed issue where an erroneous tracker could cause webtorrent to crash because socket.close was already closed after an error state --- index.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index bcac566..0c874ea 100644 --- a/index.js +++ b/index.js @@ -180,13 +180,11 @@ Tracker.prototype._requestUdp = function (requestUrl, opts) { function error (message) { self.client.emit('error', new Error(message + ' (connecting to tracker ' + requestUrl + ')')) - socket.close() + try { socket.close() } catch (e) { } clearTimeout(timeout) } - socket.on('error', function (err) { - error(err) - }) + socket.on('error', error) socket.on('message', function (message, rinfo) {