From 03021f7c2bc98f38824e742aa6415f9fafe574cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=85=E8=86=80?= Date: Fri, 23 Oct 2026 23:22:58 +0800 Subject: [PATCH] fix(telegram): bound individual api requests Bound individual platform calls so they cannot outlive the lock protecting a message update or stall a whole delivery invocation. --- server/lib/drivers/telegram/rest.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/lib/drivers/telegram/rest.ts b/server/lib/drivers/telegram/rest.ts index faf9245..8255fba 100644 --- a/server/lib/drivers/telegram/rest.ts +++ b/server/lib/drivers/telegram/rest.ts @@ -9,6 +9,12 @@ interface TelegramResponse { result?: { message_id?: number }; } +/** + * Longest a single API call may take. Bounded, so a message edit always ends + * well within the update-chain lock it runs under (see `deliverUpdate`). + */ +export const REQUEST_TIMEOUT_MS = 15_000; + async function post( token: string, method: string, @@ -25,6 +31,7 @@ async function post( method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body), + signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS), }); lastStatus = res.status; const data = (await res.json().catch(() => null)) as TelegramResponse | null;