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

推荐订阅源

博客园 - 叶小钗
爱范儿
爱范儿
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
博客园 - 聂微东
雷峰网
雷峰网
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 三生石上(FineUI控件)
T
Tailwind CSS Blog
博客园 - Franky
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 司徒正美
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Cloudflare Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
人人都是产品经理
人人都是产品经理
宝玉的分享
宝玉的分享
罗磊的独立博客
Jina AI
Jina AI

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): kill qmd process groups · openclaw/open...
vincentkoc · 2026-06-18 · via Recent Commits to openclaw:main

@@ -3,7 +3,17 @@ import { EventEmitter } from "node:events";

33

import fs from "node:fs/promises";

44

import os from "node:os";

55

import path from "node:path";

6-

import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";

6+

import {

7+

afterAll,

8+

afterEach,

9+

beforeAll,

10+

beforeEach,

11+

describe,

12+

expect,

13+

it,

14+

vi,

15+

type MockInstance,

16+

} from "vitest";

717

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

818919

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

@@ -24,13 +34,15 @@ import {

2434

type QmdBinaryAvailability,

2535

} from "./qmd-process.js";

263627-

function createMockChild() {

37+

function createMockChild(params: { pid?: number } = {}) {

2838

const child = new EventEmitter() as EventEmitter & {

39+

pid?: number;

2940

stdout: EventEmitter;

3041

stderr: EventEmitter;

3142

kill: ReturnType<typeof vi.fn>;

3243

closeWith: (code?: number | null, signal?: NodeJS.Signals | null) => void;

3344

};

45+

child.pid = params.pid;

3446

child.stdout = new EventEmitter();

3547

child.stderr = new EventEmitter();

3648

child.kill = vi.fn();

@@ -42,7 +54,7 @@ function createMockChild() {

42544355

let fixtureRoot = "";

4456

let tempDir = "";

45-

let platformSpy: { mockRestore(): void } | null = null;

57+

let platformSpy: MockInstance<() => NodeJS.Platform> | null = null;

4658

let fixtureId = 0;

4759

const originalPath = process.env.PATH;

4860

const originalPathExt = process.env.PATHEXT;

@@ -69,6 +81,7 @@ afterEach(() => {

6981

vi.useRealTimers();

7082

process.env.PATH = originalPath;

7183

process.env.PATHEXT = originalPathExt;

84+

platformSpy?.mockReturnValue("win32");

7285

spawnMock.mockReset();

7386

tempDir = "";

7487

});

@@ -218,6 +231,34 @@ describe("checkQmdBinaryAvailability", () => {

218231219232

expect(timeoutSpy).toHaveBeenCalledWith(expect.any(Function), MAX_SAFE_TIMEOUT_DELAY_MS);

220233

});

234+235+

it("kills timed-out availability probes by process group on POSIX", async () => {

236+

platformSpy?.mockReturnValue("linux");

237+

const killProcess = vi.spyOn(process, "kill").mockImplementation(() => true);

238+

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

239+

spawnMock.mockReturnValueOnce(child);

240+241+

try {

242+

await expect(

243+

checkQmdBinaryAvailability({

244+

command: "qmd",

245+

env: process.env,

246+

cwd: tempDir,

247+

timeoutMs: 1,

248+

}),

249+

).resolves.toEqual({

250+

available: false,

251+

reason: "binary",

252+

error: "spawn qmd timed out after 1ms",

253+

});

254+255+

expect(spawnMock.mock.calls[0]?.[2]).toMatchObject({ detached: true });

256+

expect(killProcess).toHaveBeenCalledWith(-4321, "SIGKILL");

257+

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

258+

} finally {

259+

killProcess.mockRestore();

260+

}

261+

});

221262

});

222263223264

describe("runCliCommand", () => {

@@ -341,4 +382,33 @@ describe("runCliCommand", () => {

341382342383

expect(timeoutSpy).toHaveBeenCalledWith(expect.any(Function), MAX_SAFE_TIMEOUT_DELAY_MS);

343384

});

385+386+

it("kills timed-out cli command process groups on POSIX", async () => {

387+

platformSpy?.mockReturnValue("linux");

388+

const killProcess = vi.spyOn(process, "kill").mockImplementation(() => true);

389+

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

390+

spawnMock.mockReturnValueOnce(child);

391+392+

try {

393+

const pending = runCliCommand({

394+

commandSummary: "qmd query test",

395+

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

396+

env: process.env,

397+

cwd: tempDir,

398+

maxOutputChars: 10_000,

399+

timeoutMs: 1,

400+

});

401+

const timeoutAssertion = expect(pending).rejects.toThrow(

402+

"qmd query test timed out after 1ms",

403+

);

404+405+

await timeoutAssertion;

406+407+

expect(spawnMock.mock.calls[0]?.[2]).toMatchObject({ detached: true });

408+

expect(killProcess).toHaveBeenCalledWith(-8765, "SIGKILL");

409+

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

410+

} finally {

411+

killProcess.mockRestore();

412+

}

413+

});

344414

});