Repository navigation
fix(startup): preserve preloaded resolver hooks - #128663
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 6:40 AM ET / 10:40 UTC. ClawSweeper reviewWhat this changesThe PR skips OpenClaw’s built ESM resolver shortcut when Node preloads, loaders, or configuration-file options may have registered a resolver hook, and centralizes the option parser shared with Gateway heap selection. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readinessNo blocking defect found. This active, maintainer-assigned PR repairs a current-main startup compatibility gap with exact-head built-process proof; await the remaining exact-head checks and maintainer merge decision. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherThe built CLI registers an internal Node resolver optimization before loading most of OpenClaw. Managed Gateway startup separately reads NODE_OPTIONS to preserve an explicit heap limit. flowchart LR
A[Node startup options] --> B[Shared option parser]
B --> C[Resolver hook decision]
B --> D[Gateway heap selection]
C --> E[Built CLI bootstrap]
E --> F[Internal module loading]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +25, Tests +204. Total +229 across 5 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep the conservative hook gate and shared parser, then merge after exact-head CI confirms the reviewed head. Do we have a high-confidence way to reproduce the issue? Yes. Current main unconditionally registers the short-circuiting hook, and the new built child-process cases observe whether prior preload and loader hooks still see OpenClaw runtime imports. Is this the best way to solve the issue? Yes. The shared parser removes duplicated behavior, while declining an optional optimization at the hook-registration boundary is safer than attempting to compose unknown earlier hooks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2abc76d1aebe. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
6e5540d to
44b3b41
Compare
|
Exact-head after-fix built-process proof for
These cases launch The branch was rebased only after the canonical frozen-lockfile repair #128671 landed; focused install/build/test now reach the touched source normally. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review The completed review predates rewritten head Rank-up moves:
Current-main red proof: direct |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
…ports (#131181) The startup-memory CI gate injected its RSS hook via --import, which since #128663 declines the dist ESM resolve fast path, so the gate measured a non-default slow-resolution configuration (~400 MB on Blacksmith) instead of what plain invocations pay (~243 MB). The bench now runs the launcher in-process from a wrapper with a clean execArgv and self-reports max RSS at exit. CLI bootstrap also imported proxy-capture/runtime and coverage on every non-help invocation even though capture init, finalize, and coverage warnings all no-op unless OPENCLAW_DEBUG_PROXY_ENABLED/REQUIRE is set; the import graph (sqlite capture store, proxyline, undici) now loads only when the env requests capture. Config reads import the gateway-startup metadata module directly instead of the facade that also re-exports the startup loader.
* fix(startup): preserve preloaded resolver hooks * fix(startup): preserve preloaded resolver hooks --------- Co-authored-by: Vincent Koc <[email protected]>
…ports (openclaw#131181) The startup-memory CI gate injected its RSS hook via --import, which since openclaw#128663 declines the dist ESM resolve fast path, so the gate measured a non-default slow-resolution configuration (~400 MB on Blacksmith) instead of what plain invocations pay (~243 MB). The bench now runs the launcher in-process from a wrapper with a clean execArgv and self-reports max RSS at exit. CLI bootstrap also imported proxy-capture/runtime and coverage on every non-help invocation even though capture init, finalize, and coverage warnings all no-op unless OPENCLAW_DEBUG_PROXY_ENABLED/REQUIRE is set; the import graph (sqlite capture store, proxyline, undici) now loads only when the env requests capture. Config reads import the gateway-startup metadata module directly instead of the facade that also re-exports the startup loader.
Related: #128541
What Problem This Solves
Fixes an issue where operators launching OpenClaw with a Node preload, loader,
or effective config file could silently lose resolver-hook observations during
built CLI startup.
Why This Change Was Made
The dist resolver fast path registers a later LIFO hook with
shortCircuit: true, so it must not install when an earlier hook may own the resolver chain.The fix parses
NODE_OPTIONSwith Node's actual literal-space, double-quote,and in-quote backslash grammar, shares that parser with gateway heap selection,
and conservatively declines the fast path for resolver-affecting options or
malformed input. Normal launches keep the optimization.
User Impact
Preloads and loaders continue observing OpenClaw's built runtime imports.
Launches without resolver-affecting Node options retain the existing startup
fast path.
Evidence
b55ae89f230: builtdist/entry.jsexited 0, but thepreload marker was absent for direct
--importand valid split-quotedNODE_OPTIONS.11c9ef3f529: both launches recorded./runtime-guard-Cx9Cuq24.js;dist/index.js --helpwith--loaderrecorded./runtime-C4YU4VDg.js.async loader, and split-quoted
NODE_OPTIONS.node --import tsx scripts/build-all.mts cliStartup,pnpm tsgo,node scripts/check-changed.mjs, nativescripts/pr review-tests, andgit diff --checkpassed.AI Disclosure
This pull request was prepared with AI assistance.