From 46b2b2432e8306e1faa1690b02160478541543c6 Mon Sep 17 00:00:00 2001 From: Purushoth DL Date: Tue, 17 Nov 2026 22:55:04 +0530 Subject: [PATCH] fix(plugin-runtime): exit when the app websocket closes (#845) Co-authored-by: Claude Sonnet 5.5 --- packages/plugin-runtime/src/index.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/plugin-runtime/src/index.ts b/packages/plugin-runtime/src/index.ts index 6a6660bb9..87b0e6a72 100644 --- a/packages/plugin-runtime/src/index.ts +++ b/packages/plugin-runtime/src/index.ts @@ -27,7 +27,14 @@ ws.on("message", async (e: Buffer) => { }); ws.on("open", () => console.log("Plugin runtime connected to websocket")); ws.on("error", (err: unknown) => console.error("Plugin runtime websocket error", err)); -ws.on("close", (code: number) => console.log("Plugin runtime websocket closed", code)); +ws.on("close", (code: number) => { + console.log("Plugin runtime websocket closed", code); + // The app is the only thing that talks to this process. If the connection is + // gone (e.g. the app crashed or was force-quit before it could kill us), exit + // instead of lingering as an orphan that keeps plugin servers (like the MCP + // server's port) bound. + process.exit(0); +}); // Listen for incoming events from plugins pluginToAppEvents.listen((e) => {