From 430b320cd01b104cf4aa5a590589d9ab4a8e916b Mon Sep 17 00:00:00 2001 From: Protocol-zero-0 <257158451+Protocol-zero-0@users.noreply.github.com> Date: Fri, 20 Feb 2026 15:32:57 +0000 Subject: [PATCH] fix: register crash-recording exit handler after all validation passes Move the process.on('exit') handler that records gateway crashes to after all CLI validation checks (port, auth, bind, etc.) so that user configuration errors are not incorrectly counted as gateway crashes. Addresses review feedback from @greptile-apps. Co-authored-by: Cursor --- src/cli/gateway-cli/run.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cli/gateway-cli/run.ts b/src/cli/gateway-cli/run.ts index 6fd49112d30..1e28050a2d3 100644 --- a/src/cli/gateway-cli/run.ts +++ b/src/cli/gateway-cli/run.ts @@ -215,12 +215,6 @@ async function runGatewayCommand(opts: GatewayRunOpts) { throw err; } - process.on("exit", (code) => { - if (code !== 0) { - recordGatewayCrash(stateDir); - } - }); - if (devMode) { await ensureDevGatewayConfig({ reset: Boolean(opts.reset) }); } @@ -445,6 +439,12 @@ async function runGatewayCommand(opts: GatewayRunOpts) { } : undefined; + process.on("exit", (code) => { + if (code !== 0) { + recordGatewayCrash(stateDir); + } + }); + try { await runGatewayLoop({ runtime: defaultRuntime,