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.
This commit is contained in:
翅膀 committed 2026-10-23 23:22:17 +08:00
1 parent a98ff778a2
commit ffd6cf5a36
1 file changed
+7
+7
View File
@@ -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) {