From 8d260d2f49406bc70c274fc1d63be70e073962ad Mon Sep 17 00:00:00 2001
From: Alix-007
Date: Wed, 15 Jul 2026 11:40:55 +0800
Subject: [PATCH] fix(qa-lab): prevent Telegram desktop API hangs (#107699)
---
.../src/mantis/telegram-desktop-builder.runtime.test.ts | 7 +++++++
.../qa-lab/src/mantis/telegram-desktop-builder.runtime.ts | 5 ++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/extensions/qa-lab/src/mantis/telegram-desktop-builder.runtime.test.ts b/extensions/qa-lab/src/mantis/telegram-desktop-builder.runtime.test.ts
index 465ed2da54b9..03fd16a927cd 100644
--- a/extensions/qa-lab/src/mantis/telegram-desktop-builder.runtime.test.ts
+++ b/extensions/qa-lab/src/mantis/telegram-desktop-builder.runtime.test.ts
@@ -119,6 +119,13 @@ describe("mantis Telegram desktop builder runtime", () => {
expect(remoteScript).toContain("openclaw gateway run");
expect(remoteScript).toContain("telegram-ready-message.json");
expect(remoteScript).toContain("telegram-desktop-builder.mp4");
+ expect(remoteScript).toContain(
+ "const response = await fetch(`https://api.telegram.org/bot${token}/getMe`, {\n signal: AbortSignal.timeout(15_000),\n});",
+ );
+ expect(remoteScript).toContain(
+ 'const response = await fetch(`https://api.telegram.org/bot${token}/sendMessage`, {\n method: "POST",\n headers: { "content-type": "application/json" },\n body: JSON.stringify({ chat_id: chatId, text, disable_notification: true }),\n signal: AbortSignal.timeout(15_000),\n});',
+ );
+ expect(remoteScript?.match(/signal: AbortSignal\.timeout\(15_000\)/gu)?.length).toBe(2);
expect(
commands.some((entry) => entry.command === "/tmp/crabbox" && entry.args[0] === "stop"),
).toBe(false);
diff --git a/extensions/qa-lab/src/mantis/telegram-desktop-builder.runtime.ts b/extensions/qa-lab/src/mantis/telegram-desktop-builder.runtime.ts
index 4b86137dd913..a15a0c306fa0 100644
--- a/extensions/qa-lab/src/mantis/telegram-desktop-builder.runtime.ts
+++ b/extensions/qa-lab/src/mantis/telegram-desktop-builder.runtime.ts
@@ -397,7 +397,9 @@ qa_status=0
fi
driver_user_id="$(node --input-type=module >"$out/telegram-driver-getme.json" 2>"$out/telegram-driver-getme.err" <<'MANTIS_TELEGRAM_GETME'
const token = process.env.OPENCLAW_MANTIS_TELEGRAM_DRIVER_BOT_TOKEN;
-const response = await fetch(\`https://api.telegram.org/bot\${token}/getMe\`);
+const response = await fetch(\`https://api.telegram.org/bot\${token}/getMe\`, {
+ signal: AbortSignal.timeout(15_000),
+});
const body = await response.json();
process.stdout.write(JSON.stringify({ ok: body.ok, id: body.result?.id, username: body.result?.username }));
if (!body.ok || !body.result?.id) process.exit(1);
@@ -438,6 +440,7 @@ const response = await fetch(\`https://api.telegram.org/bot\${token}/sendMessage
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ chat_id: chatId, text, disable_notification: true }),
+ signal: AbortSignal.timeout(15_000),
});
const body = await response.json();
process.stdout.write(JSON.stringify({ ok: body.ok, message_id: body.result?.message_id }));