fix(qa-lab): prevent Telegram desktop API hangs (#107699)

This commit is contained in:
Alix-007
2026-07-15 11:40:55 +08:00
committed by GitHub
parent abfdfd65b8
commit 8d260d2f49
2 changed files with 11 additions and 1 deletions

View File

@@ -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);

View File

@@ -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 }));