From ffd6cf5a366e3c369847a63dc9fdc8c037e20bc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=85=E8=86=80?= Date: Fri, 23 Oct 2026 23:22:17 +0800 Subject: [PATCH] fix(discord): bound individual api requests An unbounded API request can outlive an update-chain lock. Bound each request so another holder cannot race a late edit. --- server/lib/drivers/discord/rest.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/lib/drivers/discord/rest.ts b/server/lib/drivers/discord/rest.ts index 882b252..fa71806 100644 --- a/server/lib/drivers/discord/rest.ts +++ b/server/lib/drivers/discord/rest.ts @@ -7,6 +7,12 @@ interface DiscordMessage { id?: 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 request( url: string, method: string, @@ -23,6 +29,7 @@ async function request( "Content-Type": "application/json", }, body: JSON.stringify(message), + signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS), }); if (res.status === 429) {