From 084a5c7d3921f297d53e4538e2f580a8ca0fe8a3 Mon Sep 17 00:00:00 2001 From: Nick Pape <5674316+nick-pape@users.noreply.github.com> Date: Sun, 12 Oct 2025 13:45:22 -0500 Subject: [PATCH] Fix a lifecycle bug with server everything in stdio mode --- 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 e443a983b6..102af4f104 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(); }); }