From 9bf68da828c5b698146ac2b0160275e7591e7dcf Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 23 May 2014 20:34:23 -0700 Subject: [PATCH] udp client: add try-catches around close() --- index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 264ce7e..5bf63a6 100644 --- a/index.js +++ b/index.js @@ -230,7 +230,7 @@ Tracker.prototype._requestUdp = function (requestUrl, opts) { }) clearTimeout(timeout) - socket.close() + try { socket.close() } catch (err) {} return case 2: // scrape @@ -246,7 +246,7 @@ Tracker.prototype._requestUdp = function (requestUrl, opts) { }) clearTimeout(timeout) - socket.close() + try { socket.close() } catch (err) {} return case 3: // error @@ -257,7 +257,7 @@ Tracker.prototype._requestUdp = function (requestUrl, opts) { self.client.emit('error', new Error(msg.slice(8).toString())) clearTimeout(timeout) - socket.close() + try { socket.close() } catch (err) {} return } }) @@ -271,7 +271,7 @@ Tracker.prototype._requestUdp = function (requestUrl, opts) { function error (message) { self.client.emit('error', new Error(message + ' (connecting to tracker ' + requestUrl + ')')) - try { socket.close() } catch (e) { } + try { socket.close() } catch (err) { } clearTimeout(timeout) } @@ -849,7 +849,7 @@ Server.prototype._onUdpRequest = function (msg, rinfo) { function send (buf) { socket.send(buf, 0, buf.length, rinfo.port, rinfo.address, function () { - socket.close() + try { socket.close() } catch (err) {} }) }