惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
有赞技术团队
有赞技术团队
WordPress大学
WordPress大学
博客园 - 司徒正美
D
Docker
B
Blog
V
Visual Studio Blog
Blog — PlanetScale
Blog — PlanetScale
U
Unit 42
S
SegmentFault 最新的问题
小众软件
小众软件
J
Java Code Geeks
美团技术团队
腾讯CDC
MyScale Blog
MyScale Blog
爱范儿
爱范儿
H
Help Net Security
宝玉的分享
宝玉的分享
Microsoft Azure Blog
Microsoft Azure Blog
A
About on SuperTechFans
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
博客园 - 【当耐特】

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(e2e): bound Telegram RTT bot API calls · openclaw/ope...
vincentkoc · 2026-05-27 · via Recent Commits to openclaw:main

@@ -0,0 +1,97 @@

1+

import { spawn, spawnSync, type ChildProcessWithoutNullStreams } from "node:child_process";

2+

import { existsSync, mkdtempSync, readFileSync, rmSync } from "node:fs";

3+

import { tmpdir } from "node:os";

4+

import path from "node:path";

5+

import { setTimeout as delay } from "node:timers/promises";

6+

import { describe, expect, it } from "vitest";

7+8+

const DRIVER_SCRIPT = "scripts/e2e/npm-telegram-rtt-driver.mjs";

9+10+

async function waitForFile(filePath: string, timeoutMs = 3000): Promise<string> {

11+

const startedAt = Date.now();

12+

while (Date.now() - startedAt < timeoutMs) {

13+

if (existsSync(filePath)) {

14+

return readFileSync(filePath, "utf8");

15+

}

16+

await delay(25);

17+

}

18+

throw new Error(`timed out waiting for ${filePath}`);

19+

}

20+21+

async function stopChild(child: ChildProcessWithoutNullStreams): Promise<void> {

22+

if (child.exitCode !== null) {

23+

return;

24+

}

25+

child.kill("SIGTERM");

26+

const startedAt = Date.now();

27+

while (child.exitCode === null && Date.now() - startedAt < 1000) {

28+

await delay(25);

29+

}

30+

if (child.exitCode === null) {

31+

child.kill("SIGKILL");

32+

}

33+

}

34+35+

function startStalledJsonServer(portPath: string) {

36+

return spawn(

37+

process.execPath,

38+

[

39+

"--input-type=module",

40+

"--eval",

41+

[

42+

'import net from "node:net";',

43+

'import fs from "node:fs";',

44+

'const server = net.createServer((socket) => socket.write("HTTP/1.1 200 OK\\r\\nContent-Type: application/json\\r\\n\\r\\n"));',

45+

'server.listen(0, "127.0.0.1", () => {',

46+

" const address = server.address();",

47+

" fs.writeFileSync(process.env.PORT_FILE, String(address.port));",

48+

"});",

49+

"setInterval(() => {}, 1000);",

50+

].join("\n"),

51+

],

52+

{

53+

env: { ...process.env, PORT_FILE: portPath },

54+

stdio: "pipe",

55+

},

56+

);

57+

}

58+59+

describe("npm Telegram RTT driver", () => {

60+

it("bounds stalled Telegram Bot API response bodies", async () => {

61+

const root = mkdtempSync(path.join(tmpdir(), "openclaw-telegram-rtt-driver-"));

62+

const portPath = path.join(root, "port.txt");

63+

const outputDir = path.join(root, "out");

64+

const server = startStalledJsonServer(portPath);

65+66+

try {

67+

const port = Number.parseInt((await waitForFile(portPath)).trim(), 10);

68+

const startedAt = Date.now();

69+

const result = spawnSync(process.execPath, [DRIVER_SCRIPT], {

70+

encoding: "utf8",

71+

env: {

72+

...process.env,

73+

OPENCLAW_NPM_TELEGRAM_BOT_API_TIMEOUT_MS: "100",

74+

OPENCLAW_NPM_TELEGRAM_OUTPUT_DIR: outputDir,

75+

OPENCLAW_NPM_TELEGRAM_WARM_SAMPLES: "1",

76+

OPENCLAW_QA_TELEGRAM_API_BASE_URL: `http://127.0.0.1:${port}`,

77+

OPENCLAW_QA_TELEGRAM_CANARY_TIMEOUT_MS: "1000",

78+

OPENCLAW_QA_TELEGRAM_DRIVER_BOT_TOKEN: "driver-token",

79+

OPENCLAW_QA_TELEGRAM_GROUP_ID: "-100123",

80+

OPENCLAW_QA_TELEGRAM_SCENARIO_TIMEOUT_MS: "1000",

81+

OPENCLAW_QA_TELEGRAM_SUT_BOT_TOKEN: "sut-token",

82+

},

83+

killSignal: "SIGKILL",

84+

timeout: 2500,

85+

});

86+87+

expect(result.error).toBeUndefined();

88+

expect(result.signal).not.toBe("SIGKILL");

89+

expect(result.status).not.toBe(0);

90+

expect(result.stderr).toMatch(/abort|timed out|terminated/iu);

91+

expect(Date.now() - startedAt).toBeLessThan(2500);

92+

} finally {

93+

await stopChild(server);

94+

rmSync(root, { force: true, recursive: true });

95+

}

96+

});

97+

});