Skip to content

Commit

Permalink
fix(WebSocketConnection): make errors in event handlers throw again
Browse files Browse the repository at this point in the history
The error from something like client.on('ready', () => undefined.f);
would just be emitted as debug event instead of being thrown.

Simply moving the emitting part out of the try catch again solves this.
  • Loading branch information
SpaceEEC committed Jan 20, 2018
1 parent bf0a68d commit a22b856
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/client/websocket/WebSocketConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,15 @@ class WebSocketConnection extends EventEmitter {

this.inflate.push(data, flush && zlib.Z_SYNC_FLUSH);
if (!flush) return;
let packet;
try {
const packet = WebSocket.unpack(this.inflate.result);
this.onPacket(packet);
if (this.client.listenerCount('raw')) this.client.emit('raw', packet);
packet = WebSocket.unpack(this.inflate.result);
} catch (err) {
this.client.emit('debug', err);
return;
}
this.onPacket(packet);
if (this.client.listenerCount('raw')) this.client.emit('raw', packet);
}

/**
Expand Down

0 comments on commit a22b856

Please sign in to comment.