Repository navigation
fix(update): prevent Doctor OOM during finalization - #126141
clawsweeper wants to merge 3 commits into
Conversation
Co-authored-by: hannesrudolph <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs changes before merge. Reviewed August 19, 2026, 12:15 AM ET / 04:15 UTC. ClawSweeper reviewWhat this changesThe PR applies an 8 GiB Node heap policy before update commands start and shares that policy with updater build work. Merge readiness⛔ Blocked by patch quality or review findings - 8 items remain Needs changes before merge: two prior P1 concerns remain on the current head—valid inherited heap caps can be overridden, and the legacy root Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherThe CLI can respawn itself before dispatching a command so Node startup settings take effect. Update and repair commands then run Doctor and finalization in that child process. flowchart LR
A[Update command] --> B[CLI startup]
B --> C[Respawn policy]
C --> D[Heap option handling]
D --> E[Update process]
E --> F[Doctor finalization]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +15, Tests +4. Total +19 across 4 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Centralize Node-option tokenization and explicit heap-cap detection, preserve every valid inherited cap, and normalize the legacy update alias before startup classification; use 8 GiB only when no cap exists. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection and direct Node runtime checks show valid alternate heap-cap syntax is overwritten, while raw Is this the best way to solve the issue? No. The current helper is a plausible mitigation but does not preserve Node’s accepted explicit cap forms or cover the existing root update alias. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6c26bc7e2bab. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
Co-authored-by: hannesrudolph <[email protected]>
|
Closing this approach in favor of the owner-level repair in #126115. The reported failure is real, and the larger heap successfully demonstrates a containment path. However, the stronger current-source match is Doctor repeatedly materializing the complete SQLite session corpus: full The startup-respawn implementation also does not cover the documented no-respawn and root I am keeping #126115 open and replacing this with a bounded Doctor/session-accessor refactor plus a generated large-corpus, low-heap regression and before/after memory measurements. Hannes remains credited for the report and reproduction evidence. |
|
Follow-up: the owner-level replacement has landed in #126353 as 61221c4c20ec511ba239648a5f4f7998d5c35459. Thank you, Hannes, for the detailed reproduction and for demonstrating that an 8 GiB heap allowed the stranded update to recover. That evidence was the key lead, but the final repair went deeper than the heap workaround in this PR. The root cause was Doctor and session SQLite migration/repair code retaining complete We proved the real built Node 24 Doctor flow under a 768 MiB old-space cap:
Exact-head CI passed, including 205 focused assertions, the broader 331-test pass, build/check gates, and clean autoreview. Your credit is preserved in the landed squash commit via #126115 is now closed. The fix is merged to |
Closes #126115
AI-assisted: yes (Codex / Roboclaw)
What Problem This Solves
Package-to-dev updates could reach post-update Doctor with Node's default roughly 2 GiB heap. Large recovered state could exhaust that heap, abort finalization, and leave the Gateway stopped until the operator supplied a manual
NODE_OPTIONSoverride.Why This Change Was Made
Apply the updater's existing 8 GiB heap budget at the CLI startup boundary for
updatecommands other thanupdate status. This covers normal updates, post-core finalization, and directupdate repairbefore Doctor can load recovered state. The same small helper remains the source-build budget owner, preserves larger operator limits, and keeps unrelated Node options.The earlier broad finalizer/Doctor rework was removed. Final PR scope is four files with one fast boundary assertion; there is no spawned-Node regression test or update-flow test expansion.
User Impact
Operators with large retained or recovered state can complete update finalization without discovering and supplying a manual heap override. Existing higher heap limits remain intact.
Evidence
update repairupgrades a 1 GiB limit to 8 GiB while preserving unrelated startup environment; this assertion fails on the pre-fix code.node scripts/run-vitest.mjs src/entry.respawn.test.ts src/infra/update-runner.test.ts— 93 tests passed across two shards; the added boundary assertion runs in the 9 ms respawn-test shard.node scripts/check-changed.mjs -- src/entry.respawn.ts src/entry.respawn.test.ts src/infra/update-node-options.ts src/infra/update-runner-git-commands.ts— passed formatting, dead-export analysis, production/test typecheck, lint, import-cycle, architecture, and repository guards..agents/skills/autoreview/scripts/autoreview --mode local --stream-engine-output— clean; no accepted/actionable findings.The reporter's private recovered state fixture is unavailable, so this PR does not claim a replay of the exact reported corpus. The regression targets the startup resource boundary that must be established before V8 and Doctor begin work.