From 867d2af6ac2aea11bb23a470f98867cd11b1f484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=85=E8=86=80?= Date: Fri, 23 Oct 2026 23:23:03 +0800 Subject: [PATCH] fix(telegram): report unreadable send results An unreadable successful response may already have sent the message. Report an explicit uncertain result instead of retrying a create without an idempotency key or pretending it succeeded. --- server/lib/drivers/telegram/rest.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/server/lib/drivers/telegram/rest.ts b/server/lib/drivers/telegram/rest.ts index 5981f1f..bef42a7 100644 --- a/server/lib/drivers/telegram/rest.ts +++ b/server/lib/drivers/telegram/rest.ts @@ -76,10 +76,25 @@ async function post( }; } + // Accepted, but the answer is unreadable (cut off, timed out): the + // message may well exist, and Telegram has no idempotency key, so a + // retry could post it twice — a visible failure, not retried (and not + // a success without a message id, which an update chain would lose). + if (data?.ok !== true) { + log.error({ status: res.status, chatId }, "Unreadable Telegram response"); + return { + ok: false, + error: "Telegram accepted the request, but its answer could not be read", + errorCode: "TELEGRAM_UNCERTAIN", + status: res.status, + attempts: attempt + 1, + }; + } + return { ok: true, status: res.status, - messageId: data?.result?.message_id != null ? String(data.result.message_id) : undefined, + messageId: data.result?.message_id != null ? String(data.result.message_id) : undefined, attempts: attempt + 1, }; } catch (err) {