From 76dcff0617946c921aad9bc4ef55eb53e8365458 Mon Sep 17 00:00:00 2001 From: Nick Pape <5674316+nick-pape@users.noreply.github.com> Date: Tue, 25 Nov 2025 15:50:31 -0600 Subject: [PATCH] Fix a lifecycle bug with server everything in stdio mode (#2848) --- src/everything/stdio.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/everything/stdio.ts b/src/everything/stdio.ts index e443a983..102af4f1 100644 --- a/src/everything/stdio.ts +++ b/src/everything/stdio.ts @@ -9,14 +9,18 @@ async function main() { const transport = new StdioServerTransport(); const {server, cleanup, startNotificationIntervals} = createServer(); + // Cleanup when client disconnects + server.onclose = async () => { + await cleanup(); + process.exit(0); + }; + await server.connect(transport); startNotificationIntervals(); // Cleanup on exit process.on("SIGINT", async () => { - await cleanup(); - await server.close(); - process.exit(0); + await server.close(); }); }