This commit is contained in:
Erik 2023-12-10 23:04:28 +02:00
parent 4ab7f33767
commit 55aafa5cb7

View File

@ -130,8 +130,9 @@ class Shard extends EventEmitter
return new Promise((resolve, reject) => return new Promise((resolve, reject) =>
{ {
const cleanup = () => const cleanup = (kill?: boolean) =>
{ {
if (kill)
this.#process?.kill(); this.#process?.kill();
clearTimeout(spawnTimeoutTimer); // eslint-disable-line @typescript-eslint/no-use-before-define 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('ready', onReady); // eslint-disable-line @typescript-eslint/no-use-before-define
@ -147,7 +148,7 @@ class Shard extends EventEmitter
const onDisconnect = () => const onDisconnect = () =>
{ {
cleanup(); cleanup(true);
reject(new Error(`[shard${this.id}] Shard disconnected while readying.`)); reject(new Error(`[shard${this.id}] Shard disconnected while readying.`));
}; };
@ -159,7 +160,7 @@ class Shard extends EventEmitter
const onTimeout = () => const onTimeout = () =>
{ {
cleanup(); cleanup(true);
reject(new Error(`[shard${this.id}] Shard timed out while readying.`)); reject(new Error(`[shard${this.id}] Shard timed out while readying.`));
}; };
@ -428,7 +429,7 @@ class Shard extends EventEmitter
if (code !== 0) if (code !== 0)
{ {
this.#crashes.push(Date.now() - this.spawnedAt); 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; this.#ready = false;