Skip to content

Commit 5ee7d77

Browse files
committed
Addressed Claude PR review comments: Added tsx dev dependency, beefed up process termination (possible leak on Windows), beefed up http server cleanup (close all connections), removed unused hasValidJsonOutput, reduced CLI timeout to give it breathing room with vitest timeout.
1 parent f57bc30 commit 5ee7d77

File tree

5 files changed

+13
-45
lines changed

5 files changed

+13
-45
lines changed

cli/__tests__/helpers/assertions.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,3 @@ export function expectJsonStructure(result: CliResult, expectedKeys: string[]) {
5050
});
5151
return json;
5252
}
53-
54-
/**
55-
* Check if output contains valid JSON (for tools/resources/prompts responses)
56-
*/
57-
export function hasValidJsonOutput(output: string): boolean {
58-
return (
59-
output.includes('"tools"') ||
60-
output.includes('"resources"') ||
61-
output.includes('"prompts"') ||
62-
output.includes('"content"') ||
63-
output.includes('"messages"') ||
64-
output.includes('"contents"')
65-
);
66-
}

cli/__tests__/helpers/cli-runner.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,26 @@ export async function runCli(
4141
let stderr = "";
4242
let resolved = false;
4343

44-
// Default timeout of 12 seconds (less than vitest's 15s)
45-
const timeoutMs = options.timeout ?? 12000;
44+
// Default timeout of 10 seconds (less than vitest's 15s)
45+
const timeoutMs = options.timeout ?? 10000;
4646
const timeout = setTimeout(() => {
4747
if (!resolved) {
4848
resolved = true;
4949
// Kill the process and all its children
5050
try {
5151
if (process.platform === "win32") {
52-
child.kill();
52+
child.kill("SIGTERM");
5353
} else {
5454
// On Unix, kill the process group
5555
process.kill(-child.pid!, "SIGTERM");
5656
}
5757
} catch (e) {
58-
// Process might already be dead
59-
child.kill();
58+
// Process might already be dead, try direct kill
59+
try {
60+
child.kill("SIGKILL");
61+
} catch (e2) {
62+
// Process is definitely dead
63+
}
6064
}
6165
reject(new Error(`CLI command timed out after ${timeoutMs}ms`));
6266
}

cli/__tests__/helpers/instrumented-server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,8 @@ export class InstrumentedServer {
422422

423423
if (this.httpServer) {
424424
return new Promise((resolve) => {
425+
// Force close all connections
426+
this.httpServer!.closeAllConnections?.();
425427
this.httpServer!.close(() => {
426428
this.httpServer = undefined;
427429
resolve();

cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
},
2727
"devDependencies": {
2828
"@types/express": "^5.0.6",
29+
"tsx": "^4.7.0",
2930
"vitest": "^4.0.17"
3031
},
3132
"dependencies": {

package-lock.json

Lines changed: 1 addition & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)