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;