Skip to content

Commit 25b31c7

Browse files
committed
test(mcp): stabilize process cleanup proof
1 parent 130a373 commit 25b31c7

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

‎src/agents/mcp-stdio-transport.process.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ describe.skipIf(process.platform === "win32")("OpenClaw stdio process-group owne
1515
const root = tempDirs.make("mcp-stdio-descendant-");
1616
const serverPath = path.join(root, "leader.mjs");
1717
const descendantPidPath = path.join(root, "descendant.pid");
18+
const exitMarkerPath = path.join(root, "exit.marker");
1819
await fs.writeFile(
1920
serverPath,
20-
`import {spawn} from "node:child_process"; import fs from "node:fs"; const child=spawn(process.execPath,["-e","setInterval(()=>{},1000)"],{stdio:"ignore"}); fs.writeFileSync(${JSON.stringify(descendantPidPath)},String(child.pid)); setTimeout(()=>process.exit(1),25);`,
21+
`import {spawn} from "node:child_process"; import fs from "node:fs"; const child=spawn(process.execPath,["-e","setInterval(()=>{},1000)"],{stdio:"ignore"}); fs.writeFileSync(${JSON.stringify(descendantPidPath)},String(child.pid)); const timer=setInterval(()=>{if(fs.existsSync(${JSON.stringify(exitMarkerPath)})){clearInterval(timer);process.exit(1)}},10);`,
2122
"utf8",
2223
);
2324
const transport = new OpenClawStdioClientTransport({
@@ -37,6 +38,7 @@ describe.skipIf(process.platform === "win32")("OpenClaw stdio process-group owne
3738
descendantPid = Number(await fs.readFile(descendantPidPath, "utf8"));
3839
expect(isPidAlive(descendantPid)).toBe(true);
3940
});
41+
await fs.writeFile(exitMarkerPath, "exit", "utf8");
4042
await closed;
4143
await vi.waitFor(() => expect(isPidAlive(descendantPid)).toBe(false));
4244

‎test/scripts/lint-suppressions.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ describe("production lint suppressions", () => {
200200
"extensions/slack/src/monitor/provider-support.ts|typescript/no-unnecessary-type-parameters|1",
201201
"src/agents/agent-bundle-mcp-runtime.ts|unicorn/prefer-add-event-listener|1",
202202
"src/agents/agent-tools.abort.ts|typescript/prefer-promise-reject-errors|1",
203+
"src/agents/mcp-http-transport.ts|unicorn/prefer-add-event-listener|6",
203204
"src/agents/sessions/session-manager-entries.ts|unicorn/prefer-structured-clone|1",
204205
"src/audit/audit-event-writer.ts|unicorn/require-post-message-target-origin|2",
205206
"src/channels/plugins/channel-runtime-surface.types.ts|typescript/no-unnecessary-type-parameters|1",

0 commit comments

Comments
 (0)