From 6a0f2fdef527d155d83fe0faca631d302c99532d Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Wed, 14 Apr 2021 20:59:51 +0200 Subject: [PATCH] Update resume.ts --- src/ws/resume.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ws/resume.ts b/src/ws/resume.ts index 4c35ed60e..c8d2e1d16 100644 --- a/src/ws/resume.ts +++ b/src/ws/resume.ts @@ -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