#17230: fix: preload daemon-cli module before npm update
cli
stale
size: XS
trusted-contributor
Cluster:
Node and macOS Enhancements
## 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
#17237: fix(update): guard post-install imports after npm global update
by tdjackey · 2026-02-15
79.1%
#17764: fix: CLI update module loading - syntax fixes (v2)
by Limitless2023 · 2026-02-16
79.0%
#9062: Fix: daemon-cli barrel exports truncation causing update failures
by vishaltandale00 · 2026-02-04
75.7%
#12804: fix(daemon): use wrapper script for pnpm global installs in service...
by odinho · 2026-02-09
73.5%
#20585: fix: pre-flight ownership check before global update
by mwfj · 2026-02-19
73.1%
#19717: fix: load plugin registry before channel commands run
by MisterGuy420 · 2026-02-18
71.8%
#6064: fix(daemon): prefer bundled node from install-cli.sh over system node
by joyshmitz · 2026-02-01
71.6%
#13168: perf: short-circuit --version to skip process respawn and full modu...
by RamiNoodle733 · 2026-02-10
71.4%
#22406: Fix update detection for Companion App npm-prefix installs
by graysurf · 2026-02-21
71.1%
#13176: fix: resolve llm-task module import for global installs
by striking · 2026-02-10
71.0%