From 58f638463f1c96af2f7e6f8863fbdd0a80eced24 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 23 Jan 2026 07:17:27 +0000 Subject: [PATCH] fix: stop gateway before uninstall --- CHANGELOG.md | 1 + src/cli/daemon-cli/lifecycle.ts | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52e9126ce..0f6fee731 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ Docs: https://docs.clawd.bot - Control UI: resolve local avatar URLs with basePath across injection + identity RPC. (#1457) Thanks @dlauer. - Agents: sanitize assistant history text to strip tool-call markers. (#1456) Thanks @zerone0x. - Discord: clarify Message Content Intent onboarding hint. (#1487) Thanks @kyleok. +- Gateway: stop the service before uninstalling and fail if it remains loaded. - Agents: surface concrete API error details instead of generic AI service errors. - Exec: fall back to non-PTY when PTY spawn fails (EBADF). (#1484) - Exec approvals: allow per-segment allowlists for chained shell commands on gateway + node hosts. (#1458) Thanks @czekaj. diff --git a/src/cli/daemon-cli/lifecycle.ts b/src/cli/daemon-cli/lifecycle.ts index d5008c2d0..675d08bfb 100644 --- a/src/cli/daemon-cli/lifecycle.ts +++ b/src/cli/daemon-cli/lifecycle.ts @@ -38,6 +38,19 @@ export async function runDaemonUninstall(opts: DaemonLifecycleOptions = {}) { } const service = resolveGatewayService(); + let loaded = false; + try { + loaded = await service.isLoaded({ env: process.env }); + } catch { + loaded = false; + } + if (loaded) { + try { + await service.stop({ env: process.env, stdout }); + } catch { + // Best-effort stop; final loaded check gates success. + } + } try { await service.uninstall({ env: process.env, stdout }); } catch (err) { @@ -45,12 +58,16 @@ export async function runDaemonUninstall(opts: DaemonLifecycleOptions = {}) { return; } - let loaded = false; + loaded = false; try { loaded = await service.isLoaded({ env: process.env }); } catch { loaded = false; } + if (loaded) { + fail("Gateway service still loaded after uninstall."); + return; + } emit({ ok: true, result: "uninstalled",