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

推荐订阅源

雷峰网
雷峰网
博客园 - 聂微东
酷 壳 – CoolShell
酷 壳 – CoolShell
宝玉的分享
宝玉的分享
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
T
Tailwind CSS Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
博客园_首页
博客园 - 三生石上(FineUI控件)
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
量子位
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
人人都是产品经理
人人都是产品经理
美团技术团队
小众软件
小众软件
Jina AI
Jina AI
S
SegmentFault 最新的问题
博客园 - Franky
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com

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(memory-host-sdk): taskkill qmd process trees on windo...
vincentkoc · 2026-06-21 · via Recent Commits to openclaw:main

@@ -17,12 +17,14 @@ import {

1717

import { MAX_SAFE_TIMEOUT_DELAY_MS } from "../../../gateway-client/src/timeouts.js";

18181919

const spawnMock = vi.hoisted(() => vi.fn());

20+

const spawnSyncMock = vi.hoisted(() => vi.fn());

20212122

vi.mock("node:child_process", async () => {

2223

const actual = await vi.importActual<typeof import("node:child_process")>("node:child_process");

2324

return {

2425

...actual,

2526

spawn: spawnMock,

27+

spawnSync: spawnSyncMock,

2628

};

2729

});

2830

@@ -58,6 +60,17 @@ let platformSpy: MockInstance<() => NodeJS.Platform> | null = null;

5860

let fixtureId = 0;

5961

const originalPath = process.env.PATH;

6062

const originalPathExt = process.env.PATHEXT;

63+

const originalSystemRoot = process.env.SystemRoot;

64+

const originalWindir = process.env.WINDIR;

65+

const taskkillPath = path.win32.join("C:\\Windows", "System32", "taskkill.exe");

66+67+

function restoreEnvValue(key: string, value: string | undefined): void {

68+

if (value === undefined) {

69+

delete process.env[key];

70+

return;

71+

}

72+

process.env[key] = value;

73+

}

61746275

beforeAll(async () => {

6376

fixtureRoot = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-qmd-win-spawn-"));

@@ -75,14 +88,20 @@ afterAll(async () => {

7588

beforeEach(async () => {

7689

tempDir = path.join(fixtureRoot, `case-${fixtureId++}`);

7790

await fs.mkdir(tempDir, { recursive: true });

91+

process.env.SystemRoot = "C:\\Windows";

92+

delete process.env.WINDIR;

7893

});

79948095

afterEach(() => {

8196

vi.useRealTimers();

8297

process.env.PATH = originalPath;

8398

process.env.PATHEXT = originalPathExt;

99+

restoreEnvValue("SystemRoot", originalSystemRoot);

100+

restoreEnvValue("WINDIR", originalWindir);

84101

platformSpy?.mockReturnValue("win32");

85102

spawnMock.mockReset();

103+

spawnSyncMock.mockReset();

104+

spawnSyncMock.mockReturnValue({ status: 0 });

86105

tempDir = "";

87106

});

88107

@@ -163,7 +182,7 @@ describe("checkQmdBinaryAvailability", () => {

163182

});

164183165184

it("returns available when the qmd process spawns successfully", async () => {

166-

const child = createMockChild();

185+

const child = createMockChild({ pid: 12344 });

167186

spawnMock.mockImplementationOnce(() => {

168187

queueMicrotask(() => child.emit("spawn"));

169188

return child;

@@ -172,8 +191,35 @@ describe("checkQmdBinaryAvailability", () => {

172191

await expect(

173192

checkQmdBinaryAvailability({ command: "qmd", env: process.env, cwd: tempDir }),

174193

).resolves.toEqual({ available: true });

175-

expect(child.kill).toHaveBeenCalledTimes(1);

176-

expect(child.kill).toHaveBeenCalledWith();

194+

expect(spawnSyncMock).toHaveBeenCalledWith(taskkillPath, ["/PID", String(child.pid), "/T"], {

195+

stdio: "ignore",

196+

windowsHide: true,

197+

});

198+

expect(child.kill).not.toHaveBeenCalled();

199+

});

200+201+

it("force-kills Windows availability probes when graceful taskkill fails", async () => {

202+

const child = createMockChild({ pid: 12345 });

203+

spawnMock.mockImplementationOnce(() => {

204+

queueMicrotask(() => child.emit("spawn"));

205+

return child;

206+

});

207+

spawnSyncMock.mockReset();

208+

spawnSyncMock.mockReturnValueOnce({ status: 1 }).mockReturnValueOnce({ status: 0 });

209+210+

await expect(

211+

checkQmdBinaryAvailability({ command: "qmd", env: process.env, cwd: tempDir }),

212+

).resolves.toEqual({ available: true });

213+214+

expect(spawnSyncMock).toHaveBeenNthCalledWith(1, taskkillPath, ["/PID", "12345", "/T"], {

215+

stdio: "ignore",

216+

windowsHide: true,

217+

});

218+

expect(spawnSyncMock).toHaveBeenNthCalledWith(2, taskkillPath, ["/PID", "12345", "/T", "/F"], {

219+

stdio: "ignore",

220+

windowsHide: true,

221+

});

222+

expect(child.kill).not.toHaveBeenCalled();

177223

});

178224179225

it("returns unavailable when the qmd process cannot be spawned", async () => {

@@ -411,4 +457,26 @@ describe("runCliCommand", () => {

411457

killProcess.mockRestore();

412458

}

413459

});

460+461+

it("force-kills timed-out Windows cli commands with taskkill", async () => {

462+

const child = createMockChild({ pid: 12346 });

463+

spawnMock.mockReturnValueOnce(child);

464+465+

const pending = runCliCommand({

466+

commandSummary: "qmd query test",

467+

spawnInvocation: { command: "qmd", argv: ["query", "test", "--json"] },

468+

env: process.env,

469+

cwd: tempDir,

470+

maxOutputChars: 10_000,

471+

timeoutMs: 1,

472+

});

473+474+

await expect(pending).rejects.toThrow("qmd query test timed out after 1ms");

475+476+

expect(spawnSyncMock).toHaveBeenCalledWith(taskkillPath, ["/PID", "12346", "/T", "/F"], {

477+

stdio: "ignore",

478+

windowsHide: true,

479+

});

480+

expect(child.kill).not.toHaveBeenCalledWith("SIGKILL");

481+

});

414482

});