From 55aafa5cb7acb19b4cdbfa120d04931fb73c0d2a Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Sun, 10 Dec 2023 23:04:28 +0200 Subject: [PATCH] whoops --- src/middleware/shard/Shard.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/middleware/shard/Shard.ts b/src/middleware/shard/Shard.ts index a86d6cf..a104bf6 100644 --- a/src/middleware/shard/Shard.ts +++ b/src/middleware/shard/Shard.ts @@ -130,9 +130,10 @@ class Shard extends EventEmitter return new Promise((resolve, reject) => { - const cleanup = () => + const cleanup = (kill?: boolean) => { - this.#process?.kill(); + if (kill) + this.#process?.kill(); clearTimeout(spawnTimeoutTimer); // eslint-disable-line @typescript-eslint/no-use-before-define this.off('ready', onReady); // eslint-disable-line @typescript-eslint/no-use-before-define this.off('disconnect', onDisconnect); // eslint-disable-line @typescript-eslint/no-use-before-define @@ -147,7 +148,7 @@ class Shard extends EventEmitter const onDisconnect = () => { - cleanup(); + cleanup(true); reject(new Error(`[shard${this.id}] Shard disconnected while readying.`)); }; @@ -159,7 +160,7 @@ class Shard extends EventEmitter const onTimeout = () => { - cleanup(); + cleanup(true); reject(new Error(`[shard${this.id}] Shard timed out while readying.`)); }; @@ -428,7 +429,7 @@ class Shard extends EventEmitter if (code !== 0) { this.#crashes.push(Date.now() - this.spawnedAt); - this.emit('warn', 'Shard exited with non-zero exit code'); + this.emit('warn', 'Shard exited with non-zero exit code: ' + code); } this.#ready = false;