From b614e700fdf030c324c2647395a198496d4440f3 Mon Sep 17 00:00:00 2001 From: Evan Reichard Date: Thu, 30 Apr 2026 11:41:37 -0400 Subject: [PATCH] fix(daemon): tear down daemon when destroying all servers with no entries --- src/daemon.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/daemon.ts b/src/daemon.ts index f75e79a..9ad5f99 100644 --- a/src/daemon.ts +++ b/src/daemon.ts @@ -203,6 +203,12 @@ async function handle(req: DaemonRequest): Promise { for (const entry of toDestroy) { evict(entry, "manual destroy"); } + // Full Shutdown - If destroying all servers and nothing is left + // (including the case where no entries existed), tear down the + // daemon so it doesn't sit idle. + if (!req.serverId && entries.size === 0) { + setImmediate(() => shutdownDaemon("destroy all")); + } return { id: req.id, ok: true, @@ -223,8 +229,6 @@ async function handle(req: DaemonRequest): Promise { error: (err as Error)?.message ?? String(err), }; } - // Exhaustiveness - Should be unreachable given the union above. - throw new Error("unreachable"); } // Handle Connection - Reads NDJSON from a client socket; each line is one