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

推荐订阅源

J
Java Code Geeks
腾讯CDC
博客园 - 聂微东
爱范儿
爱范儿
罗磊的独立博客
P
Proofpoint News Feed
博客园 - Franky
博客园 - 三生石上(FineUI控件)
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
酷 壳 – CoolShell
酷 壳 – CoolShell
Jina AI
Jina AI
Blog — PlanetScale
Blog — PlanetScale
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 司徒正美
美团技术团队
MongoDB | Blog
MongoDB | Blog
WordPress大学
WordPress大学
A
About on SuperTechFans
I
InfoQ
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Help Net Security
Microsoft Azure Blog
Microsoft Azure Blog
G
Google Developers Blog

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 cron mcp probe waits · openclaw/openclaw@...
vincentkoc · 2026-06-02 · via Recent Commits to openclaw:main

@@ -4,15 +4,36 @@ import fs from "node:fs/promises";

44

import os from "node:os";

55

import path from "node:path";

66

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

7+

import { pathToFileURL } from "node:url";

78

import { promisify } from "node:util";

8-

import { assert, connectGateway, type GatewayRpcClient, waitFor } from "./mcp-channels-harness.ts";

9+

import type { GatewayRpcClient } from "./mcp-channels-harness.ts";

9101011

const execFileAsync = promisify(execFile);

12+

const PROBE_PID_WAIT_MS = readPositiveInt(

13+

process.env.OPENCLAW_CRON_MCP_CLEANUP_PID_WAIT_MS,

14+

120_000,

15+

);

16+

type McpChannelsHarness = typeof import("./mcp-channels-harness.ts");

17+

let mcpChannelsHarness: McpChannelsHarness | undefined;

11181219

type CronJob = { id?: string };

1320

type CronRunResult = { ok?: boolean; enqueued?: boolean; runId?: string };

1421

type AgentRunResult = { runId?: string; status?: string };

152223+

async function loadMcpChannelsHarness(): Promise<McpChannelsHarness> {

24+

mcpChannelsHarness ??= await import("./mcp-channels-harness.ts");

25+

return mcpChannelsHarness;

26+

}

27+28+

function readPositiveInt(raw: string | undefined, fallback: number): number {

29+

const text = (raw ?? "").trim();

30+

if (!/^\d+$/u.test(text)) {

31+

return fallback;

32+

}

33+

const parsed = Number(text);

34+

return Number.isInteger(parsed) && parsed > 0 ? parsed : fallback;

35+

}

36+1637

async function readProbePid(pidPath: string): Promise<number | undefined> {

1738

try {

1839

const raw = (await fs.readFile(pidPath, "utf-8")).trim();

@@ -52,14 +73,19 @@ async function describeProbePid(pid: number): Promise<string | undefined> {

5273

}

5374

}

547555-

async function waitForProbePid(pidPath: string): Promise<number | undefined> {

76+

export async function waitForProbePid(

77+

pidPath: string,

78+

options: { pollMs?: number; timeoutMs?: number } = {},

79+

): Promise<number | undefined> {

80+

const timeoutMs = options.timeoutMs ?? PROBE_PID_WAIT_MS;

81+

const pollMs = options.pollMs ?? 100;

5682

const startedAt = Date.now();

57-

while (Date.now() - startedAt < 600_000) {

83+

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

5884

const pid = await readProbePid(pidPath);

5985

if (pid) {

6086

return pid;

6187

}

62-

await delay(100);

88+

await delay(pollMs);

6389

}

6490

return undefined;

6591

}

@@ -128,6 +154,7 @@ async function runCronCleanupScenario(params: {

128154

gateway: GatewayRpcClient;

129155

pidPath: string;

130156

}): Promise<{ jobId: string; runId?: string; pid: number; status?: unknown }> {

157+

const { assert, waitFor } = await loadMcpChannelsHarness();

131158

const { gateway, pidPath } = params;

132159

const job = await gateway.request<CronJob>("cron.add", {

133160

name: "cron mcp cleanup docker e2e",

@@ -171,7 +198,7 @@ async function runCronCleanupScenario(params: {

171198

const pid = await waitForProbePid(pidPath);

172199

assert(

173200

pid,

174-

`cron MCP probe did not start; missing pid file at ${pidPath}; events=${JSON.stringify(

201+

`cron MCP probe did not start within ${PROBE_PID_WAIT_MS}ms; missing pid file at ${pidPath}; events=${JSON.stringify(

175202

gateway.events.slice(-10),

176203

)}`,

177204

);

@@ -209,6 +236,7 @@ async function runSubagentCleanupScenario(params: {

209236

pidsPath: string;

210237

exitPath: string;

211238

}): Promise<{ runId: string; exitedPids: number[]; pids: number[] }> {

239+

const { assert } = await loadMcpChannelsHarness();

212240

const { gateway, pidPath, pidsPath, exitPath } = params;

213241

await resetProbeFiles({ pidPath, pidsPath, exitPath });

214242

@@ -258,6 +286,7 @@ async function runSubagentCleanupScenario(params: {

258286

}

259287260288

async function main() {

289+

const { assert, connectGateway } = await loadMcpChannelsHarness();

261290

const gatewayUrl = process.env.GW_URL?.trim();

262291

const gatewayToken = process.env.GW_TOKEN?.trim();

263292

const stateDir = process.env.OPENCLAW_STATE_DIR?.trim() || path.join(os.homedir(), ".openclaw");

@@ -283,4 +312,6 @@ async function main() {

283312

}

284313

}

285314286-

await main();

315+

if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {

316+

await main();

317+

}