From ff764ee6903fba94fa618d32317c472a2b4cf288 Mon Sep 17 00:00:00 2001 From: merlin Date: Mon, 9 Mar 2026 12:36:05 +0800 Subject: [PATCH] fix: release gateway lock on restart failure + reply to Codex reviews - Release gateway lock when in-process restart fails, so daemon restart/stop can still manage the process (Codex P2) - P1 (env mismatch) already addressed: best-effort by design, documented in JSDoc --- src/cli/gateway-cli/run-loop.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cli/gateway-cli/run-loop.ts b/src/cli/gateway-cli/run-loop.ts index f6fc2a1d091..4fbb4807264 100644 --- a/src/cli/gateway-cli/run-loop.ts +++ b/src/cli/gateway-cli/run-loop.ts @@ -206,6 +206,11 @@ export async function runGatewayLoop(params: { throw err; } server = null; + // Release the gateway lock so that `daemon restart/stop` (which + // discovers PIDs via the gateway port) can still manage the process. + // Without this, the process holds the lock but is not listening, + // forcing manual cleanup. (#35862) + await releaseLockIfHeld(); const errMsg = err instanceof Error ? err.message : String(err); const errStack = err instanceof Error && err.stack ? `\n${err.stack}` : ""; gatewayLog.error(