Skip to content

Commit

Permalink
Defer heartbeat during resume
Browse files Browse the repository at this point in the history
Hotfix for #921 and discord / discord-api-docs # 1619 until they deploy that
  • Loading branch information
abalabahaha committed May 13, 2020
1 parent dc4c4e7 commit fc655e2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/gateway/Shard.js
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,9 @@ class Shard extends EventEmitter {
this.client.shards._readyPacketCB();

if(packet.t === "RESUMED") {
// Can only heartbeat after resume succeeds, discord/discord-api-docs#1619
this.heartbeat();

This comment has been minimized.

Copy link
@night

night May 13, 2020

you do not need to heartbeat after a identify/resume, as identifying/resuming resets your heartbeat technically. but it doesn't hurt.


this.preReady = true;
this.ready = true;

Expand Down Expand Up @@ -1934,8 +1937,9 @@ class Shard extends EventEmitter {
this.resume();
} else {
this.identify();
// Cannot heartbeat when resuming, discord/discord-api-docs#1619
this.heartbeat();
}
this.heartbeat();
/**
* Fired when a shard receives an OP:10/HELLO packet
* @event Client#hello
Expand All @@ -1959,6 +1963,10 @@ class Shard extends EventEmitter {
}

heartbeat(normal) {
// Can only heartbeat after resume succeeds, discord/discord-api-docs#1619
if(this.status === "resuming") {
return;
}
if(normal) {
if(!this.lastHeartbeatAck) {
this.emit("debug", "Heartbeat timeout; " + JSON.stringify({
Expand Down

0 comments on commit fc655e2

Please sign in to comment.