Repository navigation
fix(daemon): pin Node heap ceiling via CLI flag for managed services - #97334
CCcassiusdjs wants to merge 1 commit into
Conversation
openclaw daemon install generated launchd/systemd commands that launched the gateway under Node's default old-space ceiling (~min(host RAM/2, 4 GB)). Under sustained multi-agent load with accumulated cron/journal state the heap overshoots that ceiling and the gateway OOM crash-loops (reported: 2314 restarts/day), blocking all workflow processing. Inject --max-old-space-size=8192 as a Node CLI argument in the launch command (launchd ProgramArguments / systemd ExecStart), not via NODE_OPTIONS: that env key is on the host-env-security blocked-everywhere list, so setting it would be stripped/insecure. The flag is added only for the Node runtime; bun uses its own allocator and an operator wrapper owns its runtime flags. Fixes #96203
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Keep this PR open but not merge-ready: the CLI-flag approach avoids the blocked Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Close this PR as superseded by #96250. So I’m closing this here and keeping the remaining discussion on #96250. Review detailsBest possible solution: Close this PR as superseded by #96250. Do we have a high-confidence way to reproduce the issue? No for the full 30-agent OOM crash loop in this read-only review; the linked issue has strong live evidence and source inspection confirms current main lacks a managed heap flag. The PR-introduced repair regression is source-reproducible from the new argv shape and the existing Is this the best way to solve the issue? No, not yet. The CLI-arg approach is a promising security-aligned mitigation, but the best fix must also update downstream argv consumers and include real daemon install proof. Security review: Security review cleared: Cleared: the diff adds no dependencies, permissions, or secret handling, and the CLI-flag shape avoids generating the blocked AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 3630d502eb9b. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6973a25149
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const cliEntrypointPath = await resolveCliEntrypointPathForService(); | ||
| return { | ||
| programArguments: [nodePath, cliEntrypointPath, ...params.args], | ||
| programArguments: [nodePath, NODE_SERVICE_HEAP_FLAG, cliEntrypointPath, ...params.args], |
There was a problem hiding this comment.
Update service-command parsers for inserted Node flags
When gateway install now writes [node, --max-old-space-size=8192, entrypoint, gateway], consumers still assume the old [node, entrypoint, gateway] shape: resolveManagedServiceNodeRunner reads args[gatewayIndex - 2] in src/cli/update-cli/update-command.ts:1496-1501, so openclaw update no longer detects/uses the service Node, and collectGatewayServiceStartRepairIssues checks only programArguments.slice(0, 2) in src/daemon/service.ts:155, so missing entrypoints at index 2 are no longer caught. This affects newly installed Node services during updates or restart repair; please teach those parsers to skip Node flags or share a normalized service-command parser before changing the generated command shape.
Useful? React with 👍 / 👎.
|
ClawSweeper applied the proposed close for this PR.
|
|
Thanks for the review — the start-repair point was correct and I've fixed it. Regression you flagged: Fix (new commit On the remaining points:
Still offered as the security-aligned alternative to #96250 (CLI flag vs the |
Closes #96203
What Problem This Solves
Fixes an issue where operators running the managed gateway under sustained load
experience repeated OOM crash-loops.
openclaw daemon installgenerated launchd/systemd launch commandsthat started the gateway under Node's default V8 old-space ceiling
(~
min(host RAM/2, 4 GB)). Under sustained multi-agent load with accumulatedcron/journal state, the heap overshoots that ceiling and the gateway OOM
crash-loops (reported: 2314 restarts in one day), blocking all workflow
processing.
Why This Change Was Made
The naive fix — setting
NODE_OPTIONS=--max-old-space-size=...in the serviceenvironment — is wrong here:
NODE_OPTIONSis on the host-env-securityblockedEverywherekey list (src/infra/host-env-security-policy.json). Thebuilder output is not run through that filter and
renderEnvDictdoes not stripit, so the value would leak into the generated plist — exactly the key the
security policy says must never be a managed env var.
Instead, this pins
--max-old-space-size=8192as a Node CLI argument in thelaunch command (
resolveCliProgramArgumentsinsrc/daemon/program-args.ts),which feeds both launchd
ProgramArgumentsand systemdExecStart. Thissidesteps the env-key policy entirely. The flag is injected only for the Node
runtime; bun uses its own allocator and ignores the V8 flag, and an operator
OPENCLAW_WRAPPERowns its own runtime flags.User Impact
Managed gateway/node services get a stable heap ceiling out of the box. The
ceiling is a cap, not an allocation — steady-state RSS is unaffected (reported
~700 MB). No new config/env surface added. Bun and wrapper installs are
unchanged.
Evidence
after the fix; bun/wrapper negative tests stay green.
buildSystemdUnitandbuildLaunchAgentPlistfrom the real builder output and asserts--max-old-space-size=8192appears in the systemdExecStartand the launchdplist
ProgramArguments.program-args.test.ts: 13/13. Consumer suites (launchd, systemd, service,daemon-install-helpers, node-daemon-install-helpers, doctor-gateway-daemon-flow,
configure.daemon, service-audit, inspect, schtasks): 397 passed, 0 failed.
oxlintclean;tsgo:coreandtsgo:core:testclean.Proof boundary
Verified at the rendered-artifact level (unit/plist text), not live on a
running macOS launchd daemon. Demonstration branch.