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

推荐订阅源

Recent Announcements
Recent Announcements
人人都是产品经理
人人都是产品经理
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
GbyAI
GbyAI
博客园 - 司徒正美
美团技术团队
Vercel News
Vercel News
IT之家
IT之家
U
Unit 42
Y
Y Combinator Blog
罗磊的独立博客
Microsoft Security Blog
Microsoft Security Blog
MongoDB | Blog
MongoDB | Blog
Jina AI
Jina AI
V
Visual Studio Blog
B
Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
MyScale Blog
MyScale Blog
博客园 - 叶小钗
A
About on SuperTechFans
WordPress大学
WordPress大学
Hugging Face - Blog
Hugging Face - Blog
B
Blog RSS Feed

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
test: guard process child adapter calls · openclaw/opencl...
steipete · 2026-05-12 · via Recent Commits to openclaw:main

@@ -76,6 +76,36 @@ async function createAdapterHarness(params?: {

7676

return { adapter, killMock };

7777

}

787879+

type SpawnWithFallbackParams = {

80+

argv?: string[];

81+

options?: {

82+

detached?: boolean;

83+

env?: NodeJS.ProcessEnv | Record<string, string>;

84+

stdio?: string[];

85+

};

86+

fallbacks?: Array<{ options?: { detached?: boolean } }>;

87+

};

88+89+

function firstSpawnWithFallbackParams(): SpawnWithFallbackParams {

90+

const [call] = spawnWithFallbackMock.mock.calls;

91+

if (!call) {

92+

throw new Error("expected spawnWithFallback call");

93+

}

94+

const [params] = call;

95+

if (typeof params !== "object" || params === null || Array.isArray(params)) {

96+

throw new Error("expected spawnWithFallback params to be an object");

97+

}

98+

return params;

99+

}

100+101+

function firstMockArg(mock: { mock: { calls: readonly unknown[][] } }, label: string): unknown {

102+

const [call] = mock.mock.calls;

103+

if (!call) {

104+

throw new Error(`expected ${label} call`);

105+

}

106+

return call[0];

107+

}

108+79109

describe("createChildAdapter", () => {

80110

const originalServiceMarker = process.env.OPENCLAW_SERVICE_MARKER;

81111

const originalPlatformDescriptor = Object.getOwnPropertyDescriptor(process, "platform");

@@ -121,10 +151,7 @@ describe("createChildAdapter", () => {

121151

it("uses process-tree kill for default SIGKILL", async () => {

122152

const { adapter, killMock } = await createAdapterHarness({ pid: 4321 });

123153124-

const spawnArgs = spawnWithFallbackMock.mock.calls[0]?.[0] as {

125-

options?: { detached?: boolean };

126-

fallbacks?: Array<{ options?: { detached?: boolean } }>;

127-

};

154+

const spawnArgs = firstSpawnWithFallbackParams();

128155

// On Windows, detached defaults to false (headless Scheduled Task compat);

129156

// on POSIX, detached is true with a no-detach fallback.

130157

if (process.platform === "win32") {

@@ -198,9 +225,7 @@ describe("createChildAdapter", () => {

198225

argv: ["node", "-e", "setTimeout(() => {}, 1000)"],

199226

});

200227201-

const spawnArgs = spawnWithFallbackMock.mock.calls[0]?.[0] as {

202-

options?: { stdio?: Array<string> };

203-

};

228+

const spawnArgs = firstSpawnWithFallbackParams();

204229

expect(spawnArgs.options?.stdio?.[0]).toBe("inherit");

205230

expect(adapter.stdin).toBeUndefined();

206231

});

@@ -217,7 +242,7 @@ describe("createChildAdapter", () => {

217242218243

const writeCallback = vi.fn();

219244

adapter.stdin?.write("late", writeCallback);

220-

expect(writeCallback.mock.calls[0]?.[0]).toBeInstanceOf(Error);

245+

expect(firstMockArg(writeCallback, "write callback")).toBeInstanceOf(Error);

221246222247

adapter.stdin?.destroy?.();

223248

expect(adapter.stdin?.destroyed).toBe(true);

@@ -312,10 +337,7 @@ describe("createChildAdapter", () => {

312337313338

await createAdapterHarness({ pid: 7777 });

314339315-

const spawnArgs = spawnWithFallbackMock.mock.calls[0]?.[0] as {

316-

options?: { detached?: boolean };

317-

fallbacks?: Array<{ options?: { detached?: boolean } }>;

318-

};

340+

const spawnArgs = firstSpawnWithFallbackParams();

319341

expect(spawnArgs.options?.detached).toBe(false);

320342

expect(spawnArgs.fallbacks ?? []).toStrictEqual([]);

321343

});

@@ -328,10 +350,7 @@ describe("createChildAdapter", () => {

328350

argv: ["node", "-e", "process.exit(0)"],

329351

});

330352331-

const spawnArgs = spawnWithFallbackMock.mock.calls[0]?.[0] as {

332-

argv?: string[];

333-

options?: { env?: NodeJS.ProcessEnv };

334-

};

353+

const spawnArgs = firstSpawnWithFallbackParams();

335354

expect(spawnArgs.argv).toEqual(["node", "-e", "process.exit(0)"]);

336355

expect(spawnArgs.options?.env).toBeUndefined();

337356

});

@@ -367,10 +386,7 @@ describe("createChildAdapter", () => {

367386

}

368387

}

369388370-

const spawnArgs = spawnWithFallbackMock.mock.calls[0]?.[0] as {

371-

argv?: string[];

372-

options?: { env?: NodeJS.ProcessEnv };

373-

};

389+

const spawnArgs = firstSpawnWithFallbackParams();

374390

expect(spawnArgs.argv?.slice(0, 4)).toEqual([

375391

"/bin/sh",

376392

"-c",

@@ -393,9 +409,7 @@ describe("createChildAdapter", () => {

393409

env: { FOO: "bar", COUNT: "12", DROP_ME: undefined },

394410

});

395411396-

const spawnArgs = spawnWithFallbackMock.mock.calls[0]?.[0] as {

397-

options?: { env?: Record<string, string> };

398-

};

412+

const spawnArgs = firstSpawnWithFallbackParams();

399413

expect(spawnArgs.options?.env).toEqual({ FOO: "bar", COUNT: "12" });

400414

});

401415