← Back to PRs

#13408: fix(gateway): skip SIGUSR1 restart in config.patch for noop reload rules

by rwmjhb open 2026-02-10 13:42 View on GitHub →
gateway stale
## Summary `config.patch` and `config.apply` previously unconditionally scheduled `scheduleGatewaySigusr1Restart()` after writing config, even when changed paths were noop-only (e.g. `agents.*`, `models.*`). This bypassed the existing reload rule logic already used by the file watcher (`diffConfigPaths()` + `buildGatewayReloadPlan()`). ## What changed - Updated `src/gateway/server-methods/config.ts`: - imported `diffConfigPaths` and `buildGatewayReloadPlan` from `../config-reload.js` - in `config.patch` and `config.apply`, compute changed paths and reload plan after writing config - schedule `scheduleGatewaySigusr1Restart()` only when `reloadPlan.restartGateway === true` - when restart is not needed, return: - `restart: { ok: true, skipped: true, reason: "no-restart-needed", noopPaths, hotReasons }` - include a `reloadPlan` summary in the response payload - Updated `src/gateway/server.config-patch.e2e.test.ts` with new cases: - skips restart when only agents-scoped paths change - still restarts when gateway-scoped paths change - skips restart for mixed noop-only changes (`agents` + `models`) - restarts when mixed changes include restart-required paths (`agents` + `gateway`) ## Test results Because the default Vitest config excludes `*.e2e.test.ts`, the e2e config was used to run this file: ```bash npx vitest run --config vitest.e2e.config.ts src/gateway/server.config-patch.e2e.test.ts ``` Result: **11 passed** ## References Fixes #5533 Refs #1997 <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR updates the gateway `config.patch` and `config.apply` RPC handlers to compute config diffs (`diffConfigPaths`) and build a reload plan (`buildGatewayReloadPlan`) when config changes are applied. The handlers now only schedule a SIGUSR1 gateway restart when the reload plan requires it, and they return reload-plan details (including noop/hot/restart reasons) to the caller. The e2e config.patch test suite adds cases asserting restart is skipped for noop-only path changes (`agents.*`, `models.*`) and still occurs for gateway-scoped changes. Overall, the change brings RPC-driven config updates in line with the existing file-watcher reload rules, reducing unnecessary restarts for noop-only config updates. <h3>Confidence Score: 3/5</h3> - Moderately safe to merge once protocol/sentinel behavior is corrected - Core restart-skipping logic is straightforward and covered by new e2e tests, but the change introduces response payload shape drift (new `reloadPlan` and a new `restart` variant) without corresponding protocol/schema updates, and it appears to still write restart sentinels even when restarts are skipped—both can break consumers or cause false restart signals. - src/gateway/server-methods/config.ts <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs