fix(telegram): bound outbound request timeouts

This commit is contained in:
Ayaan Zaidi
2026-04-29 13:50:22 +05:30
parent 14e8a2d00b
commit 071e7610d6
2 changed files with 24 additions and 1 deletions

View File

@@ -12,8 +12,15 @@ describe("resolveTelegramRequestTimeoutMs", () => {
expect(resolveTelegramRequestTimeoutMs("getupdates")).toBe(45_000);
});
it("bounds outbound delivery methods", () => {
expect(resolveTelegramRequestTimeoutMs("sendmessage")).toBe(20_000);
expect(resolveTelegramRequestTimeoutMs("sendchataction")).toBe(10_000);
expect(resolveTelegramRequestTimeoutMs("editmessagetext")).toBe(15_000);
expect(resolveTelegramRequestTimeoutMs("sendphoto")).toBe(30_000);
});
it("does not assign hard timeouts to unrelated Telegram methods", () => {
expect(resolveTelegramRequestTimeoutMs("sendmessage")).toBeUndefined();
expect(resolveTelegramRequestTimeoutMs("answercallbackquery")).toBeUndefined();
expect(resolveTelegramRequestTimeoutMs(null)).toBeUndefined();
});
});

View File

@@ -2,8 +2,24 @@ const TELEGRAM_REQUEST_TIMEOUTS_MS = {
// Bound startup/control-plane calls so the gateway cannot report Telegram as
// healthy while provider startup is still hung on Bot API setup.
deletewebhook: 15_000,
deletemessage: 15_000,
editforumtopic: 15_000,
editmessagetext: 15_000,
getchat: 15_000,
getfile: 30_000,
getme: 15_000,
getupdates: 45_000,
pinchatmessage: 15_000,
sendanimation: 30_000,
sendaudio: 30_000,
sendchataction: 10_000,
senddocument: 30_000,
sendmessage: 20_000,
sendmessagedraft: 20_000,
sendphoto: 30_000,
sendvideo: 30_000,
sendvoice: 30_000,
setmessagereaction: 10_000,
setwebhook: 15_000,
} as const;