fix(WebSocketShard): don't catch errors thrown in event handlers (#5803)

This commit is contained in:
SpaceEEC
2021-06-11 11:46:14 +02:00
committed by GitHub
parent f5f3f77286
commit 53d8e49dca

View File

@@ -291,12 +291,12 @@ class WebSocketShard extends EventEmitter {
let packet;
try {
packet = WebSocket.unpack(raw);
this.manager.client.emit(Events.RAW, packet, this.id);
if (packet.op === OPCodes.DISPATCH) this.manager.emit(packet.t, packet.d, this.id);
} catch (err) {
this.manager.client.emit(Events.SHARD_ERROR, err, this.id);
return;
}
this.manager.client.emit(Events.RAW, packet, this.id);
if (packet.op === OPCodes.DISPATCH) this.manager.emit(packet.t, packet.d, this.id);
this.onPacket(packet);
}