Repository navigation
fix(update): prevent missing-module failures during source updates - #174867
Conversation
Reuse the retained updater runtime for parent module imports while keeping original module identity. Retain the loader through process exit because CLI resource cleanup can import old hashed chunks after the update command returns. Fixes #174687. Thanks to @vishnusenthil-16 for the resolver tracing that identified the missing core chunks and their importer.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Preserve both the retained-runtime update contract and the migration-integrity guidance added on main. The live-proven production and test patch is unchanged.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR preserves the running updater’s lazy module imports after an update replaces its installed build. Example: A Git update replaces dist while the old updater still needs registry-CP3x1tRD.mjs.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR: it addresses a confirmed source-update failure through the existing retained-runtime owner, with relevant live proof and no actionable findings. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe update command retains its runtime before replacing installation files; this change extends that inventory from background workers to parent-process module resolution and loading. flowchart TD
A[Update command] --> B[Retained runtime inventory]
B --> C[Parent module hooks]
C --> D[Old updater finalization and cleanup]
A --> E[Replacement build activation]
E --> F[New Gateway]
Technical reviewBest possible solution: Use the existing retained inventory for old parent imports through process teardown while starting the replacement Gateway from the activated build. Do we have a high-confidence way to reproduce the issue? The reporter’s resolver trace, current-main retention boundary, and process regression establish the stale-chunk path; this read-only review ran no target code. Is this the best way to solve the issue? The repair addresses the shared runtime boundary instead of adding more individual preloads, preserves singleton identity, and leaves unrelated importers on their normal resolution path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f6bcd2cc92b8. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +70, Tests +101, Docs +6. Total +177 across 4 files. Added test files: 1. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 16, 2026, 8:26 PM ET / October 17, 2026, 00:26 UTC. |
… rebuild (openclaw#174867) Git-checkout updates could fail with ERR_MODULE_NOT_FOUND and roll back: the updater kept running from <checkout>/dist while git-update rebuilt dist in place, and later lazy imports in the old process (e.g. dist/port-provider importing targets, agent-db registry listing and config chunks) resolved hashed chunk names the new build had replaced. The existing updater runtime-retention owner now serves the parent process's imports from its retained bytes through process exit, including CLI cleanup after the update returns, while preserving original module URLs so singletons keep their identity. Live: an isolated git-checkout update loaded five chunks already absent from the replacement build and finished with a healthy target Gateway and a clean CLI exit. Root-cause analysis by @vishnusenthil-16. Fixes openclaw#174687
… rebuild (#174867) Git-checkout updates could fail with ERR_MODULE_NOT_FOUND and roll back: the updater kept running from <checkout>/dist while git-update rebuilt dist in place, and later lazy imports in the old process (e.g. dist/port-provider importing targets, agent-db registry listing and config chunks) resolved hashed chunk names the new build had replaced. The existing updater runtime-retention owner now serves the parent process's imports from its retained bytes through process exit, including CLI cleanup after the update returns, while preserving original module URLs so singletons keep their identity. Live: an isolated git-checkout update loaded five chunks already absent from the replacement build and finished with a healthy target Gateway and a clean CLI exit. Root-cause analysis by @vishnusenthil-16. Fixes #174687 (cherry picked from commit 714e589) Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Fixes #174687. Source updates can fail with
ERR_MODULE_NOT_FOUNDwhen the running updater lazily loads an old hashed chunk after activating the replacement build.User Impact
The updater can finish activation, Doctor, finalization, and recovery using its original runtime even after the installed build has changed.
Why This Change Was Made
Git updates already build a candidate separately, but activation replaces the installed
distwhile the original updater continues running. The existing retained-runtime owner preserved worker code; parent-process imports still resolved against the replaced installation. Reuse that same retained inventory for parent imports, preserving original module URLs and already-loaded singleton identity. The loader is scoped to retained importers and keeps the original generation available until process exit, including CLI resource cleanup after the update command returns. No new configuration, dependencies, or persistent retention mechanism.Thanks to @vishnusenthil-16 for the resolver tracing that identified the core
port-providerimporter and its missing chunks, and for the earlier backup-helper fix in #173587. That fix prepared two backup helpers; this covers remaining lazy imports through the existing runtime-retention boundary.Evidence
Regression fails without parent import retention with
ERR_MODULE_NOT_FOUNDfor the removed old hashed chunk, and passes with the fix. It covers relative and absolute imports, cold dependencies, singleton identity, original module URLs, unrelated source tooling, and a cold CLI cleanup import after the update command returns. The cleanup case also fails when hooks are retired at command return.133 tests pass across the ten retained-runtime, publication, worker-generation, and immutable-update sibling files; one existing platform-specific test is skipped. The new regression takes 1.57 seconds of test time (3.74 seconds wall time).
Core typecheck, targeted oxlint/oxfmt,
git diff --check, and Madge pass (zero cycles). A deliberatedebuggercanary fails the direct oxlint command; the real changed files are clean. The lint wrapper was stopped during unrelated plugin SDK declaration preparation, then the same installed lint engine was run directly.Runtime build (
node --import ./scripts/tsx.mjs scripts/build-all.mts qaRuntime) passes in 80.5 seconds. Fullcheck:changedSQLite inventory was omitted under the campaign's local gate budget; PR CI provides broad proof.Fresh Codex review is clean at P0–P2 after fixing its absolute-path and importer-scope findings. Production: +70/-0 lines; regression: +101/-0; documentation: +6/-0. Existing runtime retention still owns snapshots and cleanup.
Live macOS / Node 26.12.0 proof used an isolated Git checkout, HOME, state directory, and loopback port. The local fixture updated
751fad28a6d3bfc0bb3267cf7507894f052224aa→f4d53c052dfba6519783c2a4dcfc8c51c2827025; the starting revision contains this exact production patch, and the target changes a core runtime chunk. The native updater performed dependency installation, full build, copied-state Doctor/config/plugin/recovery/startup checks, activation, finalization, and foreground Gateway restart. The run finishedsucceeded; the CLI exited 0; the new Gateway's build identity matched the target, health was OK, and the synthetic workspace marker survived.After activation, 3,165 old root chunks were absent from the installed
dist. The old parent performed 1,849 retained-module loads after the observed swap, including five absent chunks (registry-CP3x1tRD.mjsandmemory-state-DRwbuuah.mjsamong them). The complete handoff log contains noERR_MODULE_NOT_FOUND, missing-module exception, or CLI cleanup failure. Conservative backup-retention warnings from native process inspection, plus expected custom-state/credential-free fixture warnings, remained nonblocking.Live entry points (paths and token omitted):
The fixture revisions are local proof commits, not published release refs. This proves the updated driver's next update; it does not retrofit already-running older updaters.