fix(plugin-runtime): exit when the app websocket closes (#845)

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Purushoth DLandClaude Sonnet 5.5 authored and GitHub committed 2026-11-17 10:25:04 -07:00
1 parent b9127dcca4
commit 46b2b2432e
1 file changed
+8 -1
+8 -1
View File
@@ -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) => {