Skip to content

Commit c4684c8

Browse files
fixed issue where an erroneous tracker could cause webtorrent to crash because socket.close was already closed after an error state
1 parent 50d3379 commit c4684c8

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,11 @@ Tracker.prototype._requestUdp = function (requestUrl, opts) {
180180

181181
function error (message) {
182182
self.client.emit('error', new Error(message + ' (connecting to tracker ' + requestUrl + ')'))
183-
socket.close()
183+
try { socket.close() } catch (e) { }
184184
clearTimeout(timeout)
185185
}
186186

187-
socket.on('error', function (err) {
188-
error(err)
189-
})
187+
socket.on('error', error)
190188

191189
socket.on('message', function (message, rinfo) {
192190

0 commit comments

Comments
 (0)