mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-18 20:21:36 +00:00
Fix "Error: listener must be a function"
The websocket can error and close before the "connection" event has fired. In that situation, socket.onMessageBound, etc. will be undefined. Closes #148
This commit is contained in:
parent
a09c51dffc
commit
fafbb25367
12
server.js
12
server.js
@ -713,13 +713,19 @@ Server.prototype._onWebSocketClose = function (socket) {
|
||||
socket.peerId = null
|
||||
socket.infoHashes = null
|
||||
|
||||
socket.removeListener('message', socket.onMessageBound)
|
||||
if (typeof socket.onMessageBound === 'function') {
|
||||
socket.removeListener('message', socket.onMessageBound)
|
||||
}
|
||||
socket.onMessageBound = null
|
||||
|
||||
socket.removeListener('error', socket.onErrorBound)
|
||||
if (typeof socket.onErrorBound === 'function') {
|
||||
socket.removeListener('error', socket.onErrorBound)
|
||||
}
|
||||
socket.onErrorBound = null
|
||||
|
||||
socket.removeListener('close', socket.onCloseBound)
|
||||
if (typeof socket.onCloseBound === 'function') {
|
||||
socket.removeListener('close', socket.onCloseBound)
|
||||
}
|
||||
socket.onCloseBound = null
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user