From 061e045a3970af1297133d5702f388a5427bd167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=85=E8=86=80?= Date: Fri, 23 Oct 2026 23:23:13 +0800 Subject: [PATCH] fix(feishu): 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/feishu/rest.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/lib/drivers/feishu/rest.ts b/server/lib/drivers/feishu/rest.ts index 248e861..b4b8fb9 100644 --- a/server/lib/drivers/feishu/rest.ts +++ b/server/lib/drivers/feishu/rest.ts @@ -11,6 +11,11 @@ interface FeishuResponse { data?: { message_id?: string } & Record; error?: { message?: string }; } +/** + * 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 feishuRequest( url: string, @@ -33,6 +38,7 @@ async function feishuRequest( method, headers, body: JSON.stringify(body), + signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS), }); lastStatus = res.status; @@ -135,6 +141,7 @@ export async function getTenantAccessToken(env: Env): Promise { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ app_id: appId, app_secret: appSecret }), + signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS), }); const data = (await res.json().catch(() => null)) as { code?: number;