From cec7006abba95f0269d058826a41f78852a6be1b Mon Sep 17 00:00:00 2001 From: Daniel dos Santos Reis Date: Mon, 9 Mar 2026 01:16:21 +0100 Subject: [PATCH] fix(gateway): exit non-zero on restart shutdown timeout When a config-change restart hits the force-exit timeout, exit with code 1 instead of 0 so launchd/systemd treats it as a failure and triggers a clean process restart. Stop-timeout stays at exit(0) since graceful stops should not cause supervisor recovery. Closes #36822 --- src/cli/gateway-cli/run-loop.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cli/gateway-cli/run-loop.ts b/src/cli/gateway-cli/run-loop.ts index c6b7d5ea21e..684e0a65c16 100644 --- a/src/cli/gateway-cli/run-loop.ts +++ b/src/cli/gateway-cli/run-loop.ts @@ -106,7 +106,10 @@ export async function runGatewayLoop(params: { const forceExitMs = isRestart ? DRAIN_TIMEOUT_MS + SHUTDOWN_TIMEOUT_MS : SHUTDOWN_TIMEOUT_MS; const forceExitTimer = setTimeout(() => { gatewayLog.error("shutdown timed out; exiting without full cleanup"); - exitProcess(0); + // Exit non-zero on restart timeout so launchd/systemd treats it as a + // failure and triggers a clean process restart instead of assuming the + // shutdown was intentional. Stop-timeout stays at 0 (graceful). (#36822) + exitProcess(isRestart ? 1 : 0); }, forceExitMs); void (async () => {