From afb18b99b705d29720713985994de85478d33be1 Mon Sep 17 00:00:00 2001 From: Voxelli <69213593+legendhimslef@users.noreply.github.com> Date: Mon, 13 Jun 2022 23:33:56 +0530 Subject: [PATCH] fix: destroy options during cleanup (#8082) --- src/client/websocket/WebSocketShard.js | 2 +- src/util/Options.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/client/websocket/WebSocketShard.js b/src/client/websocket/WebSocketShard.js index 43faa8ee85c7..326dd45b8a13 100644 --- a/src/client/websocket/WebSocketShard.js +++ b/src/client/websocket/WebSocketShard.js @@ -367,7 +367,7 @@ class WebSocketShard extends EventEmitter { if (this.connection) { this._cleanupConnection(); // Having this after _cleanupConnection to just clean up the connection and not listen to ws.onclose - this.destroy({ reset: true, emit: false, log: false }); + this.destroy({ reset: !this.sessionId, emit: false, log: false }); } this.status = Status.DISCONNECTED; this.emitClose(event); diff --git a/src/util/Options.js b/src/util/Options.js index b66c7cbc295d..83913f9462da 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -33,8 +33,9 @@ const process = require('node:process'); * @property {number|number[]|string} [shards] The shard's id to run, or an array of shard ids. If not specified, * the client will spawn {@link ClientOptions#shardCount} shards. If set to `auto`, it will fetch the * recommended amount of shards from Discord and spawn that amount - * @property {number} [closeTimeout=1] The amount of time in milliseconds to wait for the close frame to be received - * from the WebSocket. Don't have this too high/low. Its best to have it between 2_000-6_000 ms. + * @property {number} [closeTimeout=5000] The amount of time in milliseconds to wait for the close frame to be received + * from the WebSocket. + * Don't have this too high/low. It's best to have it between 2000-6000 ms. * @property {number} [shardCount=1] The total amount of shards used by all processes of this bot * (e.g. recommended shard count, shard count of the ShardingManager) * @property {CacheFactory} [makeCache] Function to create a cache.