From f2ed93c08aba970a94671a0fec819035ad989195 Mon Sep 17 00:00:00 2001 From: Marcel Menzel Date: Sat, 2 Feb 2019 11:28:45 +0100 Subject: [PATCH] fix(WebSocketShard): report correct resumed event count (#3019) This PR attempts to fix the reported resumed event count in the debug output (where it is always displayed only as 1 event replayed) and in the emitted `resumed` event, where it passed the current sequence instead of passing the actual replayed event count (which was an utopic high number for smaller bots on resume). --- src/client/websocket/WebSocketShard.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/websocket/WebSocketShard.js b/src/client/websocket/WebSocketShard.js index ea4595b41..1cf0ef1c6 100644 --- a/src/client/websocket/WebSocketShard.js +++ b/src/client/websocket/WebSocketShard.js @@ -49,7 +49,7 @@ class WebSocketShard extends EventEmitter { * @type {number} * @private */ - this.closeSequence = 0; + this.closeSequence = oldShard ? oldShard.closeSequence : 0; /** * The current session id of the WebSocket @@ -223,7 +223,7 @@ class WebSocketShard extends EventEmitter { case WSEvents.RESUMED: { this.trace = packet.d._trace; this.status = Status.READY; - const replayed = packet.s - this.sequence; + const replayed = packet.s - this.closeSequence; this.debug(`RESUMED ${this.trace.join(' -> ')} | replayed ${replayed} events.`); this.heartbeat(); break;