From 268092b56d2a8d72b3e929d4e513a5330924f4e7 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Mon, 10 Nov 2025 03:02:46 +0000 Subject: [PATCH] completionId: cgen-93704a3380484bba8ef4331270bf5498 cgen-93704a3380484bba8ef4331270bf5498 --- server/index.ts | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/server/index.ts b/server/index.ts index 92b8b066..0f801297 100644 --- a/server/index.ts +++ b/server/index.ts @@ -1703,13 +1703,23 @@ export function createServer() { for (const url of botHealthUrls) { try { console.log(`[Discord Bot Health] Trying ${url}...`); - response = await fetch(url, { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - timeout: 5000, - }); + // Create AbortController with 5 second timeout for internal Railway, 3 seconds for localhost + const isInternal = url.includes("railway.internal"); + const timeoutMs = isInternal ? 5000 : 3000; + const controller = new AbortController(); + const timeoutId = setTimeout(() => controller.abort(), timeoutMs); + + try { + response = await fetch(url, { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + signal: controller.signal, + }); + } finally { + clearTimeout(timeoutId); + } const contentType = response.headers.get("content-type") || ""; const responseBody = await response.text();