Repository navigation
fix(update): a pnpm update no longer fails after activating when the updater itself was installed by an update - #203458
Conversation
… after activation A pnpm updater that a previous OpenClaw update installed runs from its group's project-local virtual store. Activating the next version moves that group into the transaction backup, so the running updater's own `dist` disappears. Work started inside the update loads workers through the retained-runtime generation, but process-wide owners that start workers from detached or earlier async contexts (the state lease heartbeat carrier, the file-log worker pool) still resolved them from the installed package. Their spawns failed with `Cannot find module`, the plugin lifecycle lease was lost, and the update unwound as `update-recovery-pending` while the new Gateway was already serving. The retained-runtime generation now also registers a process-wide resolver for as long as it is bound, and `createCpuTrackedWorker`, which every tracked worker spawn goes through, applies it. Async-context bindings keep precedence; nothing changes outside an update that retained its runtime. `WorkerCpuHandle` and `WorkerMemoryMessage` move to `worker-cpu-types.ts` to keep `worker-cpu.ts` within its line cap.
|
🦞👀 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. |
… after activation A pnpm updater that a previous OpenClaw update installed runs from its group's project-local virtual store. Activating the next version moves that group into the transaction backup, so the running updater's own `dist` disappears. Work started inside the update loads workers through the retained-runtime generation, but process-wide owners that start workers from detached or earlier async contexts (the state lease heartbeat carrier, the file-log worker pool) still resolved them from the installed package. Their spawns failed with `Cannot find module`, the plugin lifecycle lease was lost, and the update unwound as `update-recovery-pending` while the new Gateway was already serving. The retained-runtime generation now also registers a process-wide resolver for as long as it is bound, and `createCpuTrackedWorker`, which every tracked worker spawn goes through, applies it. Async-context bindings keep precedence; nothing changes outside an update that retained its runtime. Release-line form of openclaw#203458; this line needs no type move.
… after activation A pnpm updater that a previous OpenClaw update installed runs from its group's project-local virtual store. Activating the next version moves that group into the transaction backup, so the running updater's own `dist` disappears. Work started inside the update loads workers through the retained-runtime generation, but process-wide owners that start workers from detached or earlier async contexts (the state lease heartbeat carrier, the file-log worker pool) still resolved them from the installed package. Their spawns failed with `Cannot find module`, the plugin lifecycle lease was lost, and the update unwound as `update-recovery-pending` while the new Gateway was already serving. The retained-runtime generation now also registers a process-wide resolver for as long as it is bound, and `createCpuTrackedWorker`, which every tracked worker spawn goes through, applies it. Async-context bindings keep precedence; nothing changes outside an update that retained its runtime. Release-line form of openclaw#203458; this line needs no type move.
|
Codex review: needs changes before merge. What this changesThis PR redirects detached worker launches to the updater’s retained runtime while package replacement is in progress. Example: A pnpm 12.21 installation updates from A to F1, then from F1 to F2.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this PR: it addresses a current pnpm update failure, but its spawn-time resolver breaks an existing heartbeat fixture and causes the failed CI check. Priority: P1 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe updater retains its running package before activation; worker creation consumes script paths and starts native threads that renew leases, write logs, and perform background work. flowchart TD
A[Update command] --> B[Retained runtime generation]
B --> C[Process worker resolver]
D[Detached lease and logging owners] --> E[Tracked worker creation]
C --> E
E --> F[Retained worker scripts]
Technical reviewBest possible solution: Keep the shared spawn-time relocation and make the existing heartbeat fixture leave already-retained URLs unchanged. Do we have a high-confidence way to reproduce the issue? Source confirms detached lease launches bypass the async-local generation, matching the author’s reported missing-module trace after package activation; no target code was executed during this review. Is this the best way to solve the issue? Resolving at the shared worker creation boundary covers both affected process owners without duplicating their policy; the small dependency module avoids importing the generation lifecycle into worker telemetry, and the type extraction is mechanical. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c8a643b6259b. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +42, Tests +48, Other +1. Total +91 across 6 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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 November 22, 2026, 4:47 AM ET / 09:47 UTC. |
…nly once A worker captured inside the generation was resolved again by the process-wide resolver at spawn time. The retained-runtime mapping is idempotent, but a generation's resolver need not be: the heartbeat generation test's wrapping resolver then imported itself and the worker never started (Bun shard timeout). A URL the generation already produced is now final.
…untime-detached-workers
Raw log: Red — pnpm 12.21, baseCell harness logB → C: `openclaw update --yes --json --tag /tmp/um-input/extra/openclaw-m-c.tgz` — stderrB → C: same command — stdout (JSON result)after B → C: `openclaw update status` |
Raw log: Red trace — pnpm 12.21, base, same builds, B → C run with a resolve/spawn trace preloadCell harness logresolve/spawn trace (`/tmp/um-trace.log`) during B → CB → C: `NODE_OPTIONS=--import= openclaw update --yes --json --tag /tmp/um-input/extra/openclaw-m-c.tgz` — stderr |
Raw log (continued): Red trace — pnpm 12.21, base, same builds, B → C run with a resolve/spawn trace preloadafter B → C: `openclaw update status --json` (final run record) |
Raw log: Green — pnpm 12.21, fixedCell harness logF1 → F2: `openclaw update --yes --json --tag /tmp/um-input/extra/openclaw-f2.tgz` — stderr |
Raw log (continued): Green — pnpm 12.21, fixedF1 → F2: same command — stdout (JSON result) |
Raw log (continued): Green — pnpm 12.21, fixedafter F1 → F2: `openclaw update status --json` (final run record) |
Raw log: Green — pnpm 11.28.13, fixedCell harness logF1 → F2: `openclaw update --yes --json --tag /tmp/um-input/extra/openclaw-f2.tgz` — stderr |
Raw log (continued): Green — pnpm 11.28.13, fixedF1 → F2: same command — stdout (JSON result) |
Raw log (continued): Green — pnpm 11.28.13, fixedafter F1 → F2: `openclaw update status --json` (final run record) |
Raw log: npm — fixed, unchanged behaviorCell harness logF1 → F2: `openclaw update --yes --json --tag /tmp/um-input/extra/openclaw-f2.tgz` — stderr |
Raw log (continued): npm — fixed, unchanged behaviorF1 → F2: same command — stdout (JSON result) |
Raw log (continued): npm — fixed, unchanged behaviorafter F1 → F2: `openclaw update status --json` (final run record) |
Raw log: Base npm controlCell harness logB → C: `openclaw update --yes --json --tag /tmp/um-input/extra/openclaw-m-c.tgz` — stderr |
Raw log (continued): Base npm controlB → C: same command — stdout (JSON result)after B → C: `openclaw update status` |
|
Merged via squash.
|
…updater itself was installed by an update (openclaw#203458) * fix(update): start detached workers from the retained updater runtime after activation A pnpm updater that a previous OpenClaw update installed runs from its group's project-local virtual store. Activating the next version moves that group into the transaction backup, so the running updater's own `dist` disappears. Work started inside the update loads workers through the retained-runtime generation, but process-wide owners that start workers from detached or earlier async contexts (the state lease heartbeat carrier, the file-log worker pool) still resolved them from the installed package. Their spawns failed with `Cannot find module`, the plugin lifecycle lease was lost, and the update unwound as `update-recovery-pending` while the new Gateway was already serving. The retained-runtime generation now also registers a process-wide resolver for as long as it is bound, and `createCpuTrackedWorker`, which every tracked worker spawn goes through, applies it. Async-context bindings keep precedence; nothing changes outside an update that retained its runtime. `WorkerCpuHandle` and `WorkerMemoryMessage` move to `worker-cpu-types.ts` to keep `worker-cpu.ts` within its line cap. * fix(update): resolve a captured worker through the retained runtime only once A worker captured inside the generation was resolved again by the process-wide resolver at spawn time. The retained-runtime mapping is idempotent, but a generation's resolver need not be: the heartbeat generation test's wrapping resolver then imported itself and the worker never started (Bun shard timeout). A URL the generation already produced is now final.
…es (#203241) * fix(gateway): shutdown never first-imports chunks an in-place update replaced * test(gateway): guard built shutdown against late first-imports * fix(gateway): keep broker close functions visible to dead-export scan * fix(process): supervisor shutdown warnings never first-import their logger; guard tracks pre-signal modules * test(ci): watch supervisor shutdown owners for the late-import guard * test(gateway): readable late-import entry parsing * test(gateway): stop the guard Gateway after startup maintenance settles * test(gateway): guard only hashed dist chunks that a swap removes * test(gateway): skip the SIGTERM guard where taskkill stops the Gateway * fix(gateway): prime supervisor shutdown logger from the shutdown runtime; add restart worker to PR wrapper inventory * fix(memory-core): own the manager runtime loader in a leaf module so closing never loads the provider * fix(state): agent lease cleanup handler loads with the state worker; guard stop budget and watch paths * fix(cron): claimed runs load their finalization before shutdown can need it; watch memory loader owners * fix(cron): scheduled runs also load finalization with their scheduler (cherry picked from commit 78a6ca1) Release adaptation: Preserve the stable cron dispatch preamble and command set, without main-only cron.importLegacyMemberSources; scheduler and queue still prepare finalization together. The shutdown-runtime overlap is supplied by the preceding #203185 backport. Companions: #203185 selected and applied first. #203839 replaces test process ownership separately and is not required for this guard: the stable fixture supports the same child, entrypoint and stop APIs. #203790, #202507, #202495 startup/resource changes, #201024 cgroup sizing, #197395 cron backoff, and #204210/#203458/#203271 wrapper-only overlaps are not dependencies. Co-authored-by: RomneyDa <[email protected]>
… after a pnpm activation (#205078) Port of #203458 to release/2026.11.10 as one commit. A pnpm updater that a previous OpenClaw update installed runs from its group's project-local virtual store. Activating the next version moves that group into the transaction backup, so the running updater's own `dist` disappears. Work started inside the update already loads workers through the retained-runtime generation, but process-wide owners that start workers from detached or earlier async contexts (the state lease heartbeat carrier, the file-log worker pool) still resolved them from the installed package. Their spawns failed with `Cannot find module`, the plugin lifecycle lease was lost, and the update ended `update-recovery-pending` while the new Gateway was already serving. The retained-runtime generation now also registers a process-wide resolver while it is bound, and `createCpuTrackedWorker` applies it. Async-context bindings keep precedence, a URL the generation already produced is final, and nothing changes outside an update that retained its runtime.
What Problem This Solves
Fixes: on a pnpm install, the second update between two releases that both contain this fix-line ends
update-recovery-pending(exit 1), even though the new version is installed and the Gateway serves it. Afterwards, every further update is refused with "Update has unfinished recovery; reconcile it before starting another update."User Impact
User impact: once the updater running the update contains this change, pnpm updates between OpenClaw versions end
ok, and the run is recordedsucceeded. npm installs were not affected and are unchanged.What changes nothing: a pnpm install whose updater is already a release without this change still hits the failure on its own next update, because the installed updater cannot be patched. Users who already hit it on an unfixed build stay blocked, and this PR does not change that. In a real cell, after the failed B → C, every later
openclaw update(to F1, then F2) was refused within 2 s with "Update has unfinished recovery … It belongs to the installation at ".openclaw update repairexits 1 with "Plugin cohort recovery belongs to a different installation." Settling that stranded record is a separate follow-up at the recovery-admission owner; it is described under "Not proven".Why This Change Was Made
Root cause, proven in a real cell with a resolve/spawn trace.
global/v11/<group>/node_modules/.pnpm/openclaw@…. Activating the next version moves that group into the transaction backup, so the running updater's owndistdisappears.runInDetachedAsyncContext);new Worker(…/dist/state/openclaw-state-lease-heartbeat.worker.js)and…/dist/logging/logger-file.worker.jsfrom the removed store, thenERR_MODULE_NOT_FOUND. The plugin lifecycle lease was lost ("First failure: plugin lifecycle lease core:plugin-lifecycle/global was lost … Cannot find module"). The command then unwound with the run's own unfinished recovery record.Which installs it hits.
pnpm add -g: passes. That package lives in pnpm's sharedstore/v11/links, which activation does not move.Not the cause.
completeUpdateCommandRunandassertNoPendingUpdateRecoveryare not where it fails. CLI runs never getcompletionOwner: "gateway-restart". The own-record refusal is the unwind's response to a genuine mid-activation failure; it is a consequence, not the cause. The recovery admission rule is unchanged, so an earlier run's unfinished recovery is still refused as today.Fix. While the retained-runtime generation is bound, it also registers a process-wide resolver.
createCpuTrackedWorker, through which every tracked worker spawn passes, applies it. An async-context binding still takes precedence, and outside an update that retained its runtime nothing changes. A URL the generation has already produced is final, so a worker captured in scope and then spawned is resolved once. The first CI run had shown a Bun-shard timeout in the heartbeat generation test, whose wrapping resolver imported itself when applied twice; the second commit fixes that, with a regression test that fails without it.WorkerCpuHandleandWorkerMemoryMessagemove toworker-cpu-types.tsto keepworker-cpu.tswithin its line cap. No stored field, config or schema changes.Evidence
Real cells used current-main builds A (
2026.11.20-beta.1), B and C, built frome17201c(which includes a577911), plus fixed builds F1 and F2 built from this change. Each build has its own version; nothing was relabelled. The Gateway ran as a managed service under a busy 256 MiB write load.update-recovery-pending; Gateway serves beta.3running/verifying, recovery set "ambiguous"ok; Gateway serves beta.5succeededoksucceededoksucceededoksucceededUnit regression at the owner, in
src/infra/runtime-worker-generation.test.ts:Other checks: the touched and adjacent tests pass (
worker-cpu, worker-store generation, the Gateway owner heartbeat, state lease acquisition, update-restart module outcome, eager import closure). So dopnpm tsgo:coreandtsgo:core:test, both cycle checks and the baseline ratchets.Recordings (cell log live, then a summary from the raw files):
Green, pnpm 12, A → F1 → F2:
f-pnpm12-a-f1-f2.mp4
The base failure with the resolve/spawn trace:
a-pnpm12-diag-main-e17201c-trace.mp4
Base B → C, then the blocked later updates:
f-pnpm12-heal-a-b-c-f1-f2.mp4
The raw cell logs are posted as PR comments and linked in the table above. Each comment holds the harness log and the full stderr and JSON stdout of the second update. The red cell adds
openclaw update statusafter the failure, and the other cells add the finalopenclaw update status --jsonrun record. The trace cell adds the resolve/spawn trace showing both missing worker paths andERR_MODULE_NOT_FOUND. No lines were cut; no line matched the host-identity scan.Cherry-pick for the release lines
On
release/2026.11.7(#203401) andrelease/2026.11.10(#201740) the same change applies as two commits (7413c6dplusd499c95on 2026.11.7;1d30fa2plus66e2acdon 2026.11.10), without the type move, becauseworker-cpu.tsis under its cap there. The tests andtsgo:corepass on both.Not proven
running/verifyingwith a successful recorded verification, recovery set "ambiguous", owned by a removed store path) refuses every later update, andopenclaw update repairrefuses it as "a different installation". Clearing it automatically needs the recovery-admission and reconciliation owner to settle a run whose driver is gone, whose installation root no longer exists and whose verification succeeded. That changes an admission rule, so it is left for a decision. The manual way out is not verified yet.autoreviewdoes not run on this machine.