Skip to content

Commit ad580c3

Browse files
committed
fixes for simple-websocket@4
1 parent de234ac commit ad580c3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/client/websocket-tracker.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,11 @@ WebSocketTracker.prototype._onSocketData = function (data) {
128128
var self = this
129129
if (self.destroyed) return
130130

131-
if (!(typeof data === 'object' && data !== null)) {
132-
return self.client.emit('warning', new Error('Invalid tracker response'))
131+
try {
132+
data = JSON.parse(data)
133+
} catch (err) {
134+
self.client.emit('warning', new Error('Invalid tracker response'))
135+
return
133136
}
134137

135138
if (data.info_hash !== self.client._infoHashBinary) {

0 commit comments

Comments
 (0)