← Back to PRs

#17230: fix: preload daemon-cli module before npm update

by MisterGuy420 open 2026-02-15 15:11 View on GitHub →
cli stale size: XS trusted-contributor
## Summary The CLI update command failed after npm update because the old on-disk files were deleted while the running code still referenced them. This fix adds a preload call to ensure all daemon-cli dependencies are loaded into memory before the npm update process begins. ## Changes - Added `preloadDaemonCli()` function to `src/cli/daemon-cli/lifecycle.ts` - Exported the new function from `src/cli/daemon-cli/runners.ts` and `src/cli/daemon-cli.ts` - Added preload call in `src/cli/update-cli/update-command.ts` before the npm update runs - Updated tests in `src/cli/update-cli.test.ts` to mock the new function ## Testing - All 20 existing tests in `src/cli/update-cli.test.ts` pass Fixes openclaw/openclaw#17225 <!-- greptile_comment --> <h3>Greptile Summary</h3> This PR adds preloading to prevent the CLI update command from failing after npm update deletes old files. The `preloadDaemonCli()` function loads key daemon-cli dependencies into memory before npm update runs. **Key Changes:** - Added `preloadDaemonCli()` function in `src/cli/daemon-cli/lifecycle.ts` - Exported function through `src/cli/daemon-cli/runners.ts` and `src/cli/daemon-cli.ts` - Called preload before npm update in `src/cli/update-cli/update-command.ts:572` - Tests properly mock the new function **Critical Issue Found:** - `./response.js` is not being preloaded, but it's imported by `lifecycle-core.js` and called during `runDaemonRestart()`. This will cause the same failure the PR is trying to fix. <h3>Confidence Score: 2/5</h3> - PR is not safe to merge - incomplete preloading will cause runtime failures - Score reflects a critical missing dependency (`response.js`) that will cause the exact same failure this PR is trying to fix. While the approach is correct and most dependencies are covered, the incomplete implementation means `runDaemonRestart()` will still fail after npm update when it tries to call functions from the unloaded `response.js` module. - Pay close attention to `src/cli/daemon-cli/lifecycle.ts` - the preload function needs to include `response.js` <sub>Last reviewed commit: d5d561f</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs