From d59e6e11d5e48f885420a9f38cf569eef1c010e5 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Tue, 6 Feb 2024 22:45:07 +0200 Subject: [PATCH] Bugfix for broadcastToWebhook Properly close connections on timeout --- @types/Other.ts | 2 +- src/controller/Controller.ts | 2 +- src/server/Server.ts | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/@types/Other.ts b/@types/Other.ts index a8fb316..28d38a6 100644 --- a/@types/Other.ts +++ b/@types/Other.ts @@ -52,7 +52,7 @@ export type IPCMessage = { [key: string]: string | number | object | boolean | undefined } -export type WebhookIPC = { payload: Payload, options: WebhookBroadcastOptions } +export type WebhookIPC = { payload: Payload, options?: WebhookBroadcastOptions } export type WebhookBroadcastOptions = { debounce?: { id: string | number, duration: number} diff --git a/src/controller/Controller.ts b/src/controller/Controller.ts index f3f07cf..d5323ae 100644 --- a/src/controller/Controller.ts +++ b/src/controller/Controller.ts @@ -275,7 +275,7 @@ class Controller extends EventEmitter this.#logger.debug(`Message from ${shard.id}: ${inspect(msg)}`); } - async broadcastToWebhook ({ payload, options }: WebhookIPC) + async broadcastToWebhook ({ payload, options = {} }: WebhookIPC) { if (this.#webhook) { diff --git a/src/server/Server.ts b/src/server/Server.ts index b7575ec..ac4c99e 100644 --- a/src/server/Server.ts +++ b/src/server/Server.ts @@ -567,8 +567,9 @@ class Server extends EventEmitter setTimeout(() => { this.#logger.warn('Server close timed out, cleaning up and exiting'); + this.#server?.closeAllConnections(); cleanUp(); - }, 90_000); + }, 10_000); } }