Update resume.ts

This commit is contained in:
ITOH
2021-04-14 20:59:51 +02:00
parent 1235a08f29
commit 6a0f2fdef5
+6 -2
View File
@@ -12,8 +12,11 @@ export async function resume(shardId: number) {
const oldShard = ws.shards.get(shardId);
if (oldShard) {
// HOW TO CLOSE OLD SHARD SOCKET!!!
oldShard.ws.close(3065, "Resuming the shard, closing old shard.");
// ONLY CLOSE IF SHARD SOCKET IS STILL CONNECTED
if (oldShard.ws.readyState === WebSocket.OPEN) {
// HOW TO CLOSE OLD SHARD SOCKET!!!
oldShard.ws.close(3065, "Resuming the shard, closing old shard.");
}
// STOP OLD HEARTBEAT
clearInterval(oldShard.heartbeat.intervalId);
}
@@ -40,6 +43,7 @@ export async function resume(shardId: number) {
},
queue: oldShard?.queue || [],
processingQueue: false,
queueMinuteTimestamp: Date.now(),
});
// Resume on open