mirror of
https://github.com/danbulant/discord.js
synced 2026-05-27 22:11:53 +00:00
fix(WebSocketConnection): make errors in event handlers throw again
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.
This commit is contained in:
parent
bf0a68dbac
commit
a22b856494
1 changed files with 5 additions and 3 deletions
|
|
@ -269,13 +269,15 @@ class WebSocketConnection extends EventEmitter {
|
||||||
|
|
||||||
this.inflate.push(data, flush && zlib.Z_SYNC_FLUSH);
|
this.inflate.push(data, flush && zlib.Z_SYNC_FLUSH);
|
||||||
if (!flush) return;
|
if (!flush) return;
|
||||||
|
let packet;
|
||||||
try {
|
try {
|
||||||
const packet = WebSocket.unpack(this.inflate.result);
|
packet = WebSocket.unpack(this.inflate.result);
|
||||||
this.onPacket(packet);
|
|
||||||
if (this.client.listenerCount('raw')) this.client.emit('raw', packet);
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.client.emit('debug', err);
|
this.client.emit('debug', err);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
this.onPacket(packet);
|
||||||
|
if (this.client.listenerCount('raw')) this.client.emit('raw', packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue