From e887c9743c7f40b531ea70821ec68ab14efa1952 Mon Sep 17 00:00:00 2001 From: Yida-Dev Date: Mon, 9 Feb 2026 09:37:30 +0800 Subject: [PATCH] fix: cap Discord gateway reconnect attempts to prevent infinite loop The Discord GatewayPlugin was configured with maxAttempts: Infinity, which causes an unbounded reconnection loop when the Discord gateway enters a persistent failure state (e.g. code 1005 with stalled HELLO). In production, this manifested as 2,483+ reconnection attempts in a single log file, starving the Node.js event loop and preventing cron, heartbeat, and other subsystems from functioning. Cap maxAttempts at 50, which provides ~25 minutes of retry time (with 30s HELLO timeout between attempts) before cleanly exiting via the existing "Max reconnect attempts" error handler. Closes #11836 Co-Authored-By: Claude Opus 4.6 --- src/discord/monitor/provider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/discord/monitor/provider.ts b/src/discord/monitor/provider.ts index a61016a424..5d9a986c26 100644 --- a/src/discord/monitor/provider.ts +++ b/src/discord/monitor/provider.ts @@ -504,7 +504,7 @@ export async function monitorDiscordProvider(opts: MonitorDiscordOpts = {}) { [ new GatewayPlugin({ reconnect: { - maxAttempts: Number.POSITIVE_INFINITY, + maxAttempts: 50, }, intents: resolveDiscordGatewayIntents(discordCfg.intents), autoInteractions: true,