Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/mcp-server/test/integration/e2e-apps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function readResponseById(proc: ChildProcess, id: number, timeoutMs = 15000): Pr
const msg = JSON.parse(line) as Record<string, unknown>;
if (msg["id"] === id) {
proc.stdout!.off("data", handler);
clearTimeout(timer);
resolve(msg);
return;
}
Expand All @@ -52,7 +53,11 @@ function readResponseById(proc: ChildProcess, id: number, timeoutMs = 15000): Pr
}
};
proc.stdout!.on("data", handler);
setTimeout(() => reject(new Error(`Timeout waiting for response id=${id}`)), timeoutMs);
const timer = setTimeout(() => {
proc.stdout!.off("data", handler);
reject(new Error(`Timeout waiting for response id=${id}`));
}, timeoutMs);
timer.unref();
Comment on lines 46 to +60
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same timeout and listener leak issues fixed here also exist in packages/mcp-server/test/integration/server.test.ts. That file has two similar functions (readResponse on line 14 and readResponseById on line 38) that also need:

  1. The timer handle captured and cleared on success
  2. The handler removed on timeout
  3. The timer unref'd to prevent blocking event loop exit

Consider applying the same fix pattern to those functions as well.

Copilot uses AI. Check for mistakes.
});
}

Expand Down