Skip to content

Commit d4884b4

Browse files
BrainSlugs83Copilot
andcommitted
fix: unref keepalive timer to prevent proxy hanging on exit
The setInterval keepalive ping was keeping the proxy process alive after copilot closed stdin. Adding .unref() lets Node exit cleanly when there are no other active handles. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 221e4a5 commit d4884b4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ async function callServerWithRetry(path, body) {
163163

164164
// --- Keepalive: ping server every 2 minutes to prevent idle shutdown ---
165165
const KEEPALIVE_MS = 2 * 60_000;
166-
setInterval(async () => {
166+
const keepaliveTimer = setInterval(async () => {
167167
try {
168168
const result = await ping();
169169
if (!result) {
@@ -173,6 +173,7 @@ setInterval(async () => {
173173
}
174174
} catch {}
175175
}, KEEPALIVE_MS);
176+
keepaliveTimer.unref(); // Don't block process exit for keepalive
176177

177178
// --- Start: ensure server, then expose MCP tools ---
178179

0 commit comments

Comments
 (0)