Skip to content

Commit 6740cdf

Browse files
lml2468steipete
authored andcommitted
fix(gateway): catch startup failure in run loop to prevent process exit (#35862)
When an in-process restart (SIGUSR1) triggers a config-triggered restart and the new config is invalid, params.start() throws and the while loop exits, killing the process. On macOS this loses TCC permissions. Wrap params.start() in try/catch: on failure, set server=null, log the error, and wait for the next SIGUSR1 instead of crashing.
1 parent eea925b commit 6740cdf

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/cli/gateway-cli/run-loop.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,19 @@ export async function runGatewayLoop(params: {
193193
// eslint-disable-next-line no-constant-condition
194194
while (true) {
195195
onIteration();
196-
server = await params.start();
196+
try {
197+
server = await params.start();
198+
} catch (err) {
199+
// If startup fails (e.g., invalid config after a config-triggered
200+
// restart), keep the process alive and wait for the next SIGUSR1
201+
// instead of crashing. A crash here would respawn a new process that
202+
// loses macOS Full Disk Access (TCC permissions are PID-bound). (#35862)
203+
server = null;
204+
gatewayLog.error(
205+
`gateway startup failed: ${err instanceof Error ? err.message : String(err)}. ` +
206+
"Process will stay alive; fix the issue and restart.",
207+
);
208+
}
197209
await new Promise<void>((resolve) => {
198210
restartResolver = resolve;
199211
});

0 commit comments

Comments
 (0)