Repository navigation
Conversation
…y.nodeMaxOldSpaceMb Node.js defaults to a ~1.5 GB V8 heap ceiling regardless of available RAM. On machines with 8–128 GB this leaves most memory unused and causes OOM aborts (CheckIneffectiveMarkCompact) under heavy parallel agent workloads, even though the OS has plenty of headroom. This change: - Adds `gateway.nodeMaxOldSpaceMb` to the config schema (integer, min 256, optional). When set, the value is used as-is. When absent, the gateway install plan automatically computes 85% of `os.totalmem()` at install time. - Injects the resolved limit into `NODE_OPTIONS=--max-old-space-size=N` in the service environment so the gateway process *and* any child Node processes it spawns inherit the raised ceiling automatically. - Respects an existing `--max-old-space-size` flag in the user's `NODE_OPTIONS` env var — no override in that case. - Adds an interactive prompt to the gateway onboarding wizard (non-quickstart flow) so users can see the auto-detected value and override it if needed. - Adds schema label + help text following existing conventions. - Adds 10 unit tests covering auto-detect math, env override precedence, flag composition, and buildServiceEnvironment integration.
Greptile SummaryThis PR auto-detects and injects a sane Node.js V8 heap limit (85% of system RAM) into the service environment at install time, solving OOM crashes under heavy parallel workloads. The implementation is well-structured, with clean precedence logic, an optional config override ( Issues found:
Confidence Score: 3/5
|
| const trimmed = typeof rawInput === "string" ? rawInput.trim() : ""; | ||
| const nodeMaxOldSpaceMb = trimmed ? Number.parseInt(trimmed, 10) : undefined; | ||
| nextConfig = { | ||
| ...nextConfig, | ||
| gateway: { | ||
| ...nextConfig.gateway, | ||
| ...(nodeMaxOldSpaceMb !== undefined ? { nodeMaxOldSpaceMb } : {}), | ||
| }, | ||
| }; |
There was a problem hiding this comment.
Blank input does not clear an existing nodeMaxOldSpaceMb value
When the user leaves the heap-limit field blank (to "use auto-detect"), nodeMaxOldSpaceMb is undefined and the conditional spread ...(nodeMaxOldSpaceMb !== undefined ? { nodeMaxOldSpaceMb } : {}) becomes {}. Because ...nextConfig.gateway is spread first, any previously saved nodeMaxOldSpaceMb (e.g. 6144) is retained in the resulting config rather than being removed.
The hint tells the user "Leave blank to use auto-detect", but that instruction is silently ignored if a value was previously stored. The user would need to reinstall or manually edit the config file to revert to auto-detection.
Fix: always write the resolved value (including undefined) so a blank entry explicitly clears the field:
| const trimmed = typeof rawInput === "string" ? rawInput.trim() : ""; | |
| const nodeMaxOldSpaceMb = trimmed ? Number.parseInt(trimmed, 10) : undefined; | |
| nextConfig = { | |
| ...nextConfig, | |
| gateway: { | |
| ...nextConfig.gateway, | |
| ...(nodeMaxOldSpaceMb !== undefined ? { nodeMaxOldSpaceMb } : {}), | |
| }, | |
| }; | |
| nextConfig = { | |
| ...nextConfig, | |
| gateway: { | |
| ...nextConfig.gateway, | |
| nodeMaxOldSpaceMb, | |
| }, | |
| }; |
Spreading { nodeMaxOldSpaceMb: undefined } onto the gateway object sets the key to undefined, which JSON/YAML serialisers will omit — effectively deleting the setting and restoring auto-detect behaviour.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/wizard/onboarding.gateway-config.ts
Line: 330-338
Comment:
**Blank input does not clear an existing `nodeMaxOldSpaceMb` value**
When the user leaves the heap-limit field blank (to "use auto-detect"), `nodeMaxOldSpaceMb` is `undefined` and the conditional spread `...(nodeMaxOldSpaceMb !== undefined ? { nodeMaxOldSpaceMb } : {})` becomes `{}`. Because `...nextConfig.gateway` is spread first, any previously saved `nodeMaxOldSpaceMb` (e.g. `6144`) is retained in the resulting config rather than being removed.
The hint tells the user "Leave blank to use auto-detect", but that instruction is silently ignored if a value was previously stored. The user would need to reinstall or manually edit the config file to revert to auto-detection.
Fix: always write the resolved value (including `undefined`) so a blank entry explicitly clears the field:
```suggestion
nextConfig = {
...nextConfig,
gateway: {
...nextConfig.gateway,
nodeMaxOldSpaceMb,
},
};
```
Spreading `{ nodeMaxOldSpaceMb: undefined }` onto the gateway object sets the key to `undefined`, which JSON/YAML serialisers will omit — effectively deleting the setting and restoring auto-detect behaviour.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e7930db935
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| ...nextConfig.gateway, | ||
| ...(nodeMaxOldSpaceMb !== undefined ? { nodeMaxOldSpaceMb } : {}), |
There was a problem hiding this comment.
Remove saved heap override when user leaves prompt blank
When onboarding starts with an existing gateway.nodeMaxOldSpaceMb, submitting an empty heap-limit prompt is documented as “Leave blank to use auto-detect,” but this assignment keeps the prior value because ...nextConfig.gateway already contains nodeMaxOldSpaceMb and the blank branch adds nothing. In practice, users cannot clear a previously set heap override back to auto-detect through the wizard.
Useful? React with 👍 / 👎.
…vice forwards config
- onboarding.gateway-config.ts: always spread `{ nodeMaxOldSpaceMb }` (even when
undefined) so a blank wizard entry explicitly clears a previously saved value,
restoring auto-detect behaviour as the hint promises
- service-env.ts: add nodeMaxOldSpaceMb param to buildNodeServiceEnvironment and
forward it to buildCommonServiceEnvironment so separately-installed node-host
services respect the user-configured cap rather than always using auto-detect
- node-daemon-install-helpers.ts: accept optional config and thread
config?.gateway?.nodeMaxOldSpaceMb into buildNodeServiceEnvironment
- service-env.test.ts: two new tests covering nodeMaxOldSpaceMb in node service env
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5199ee82b9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| configuredMb?: number, | ||
| ): string | undefined { | ||
| const existing = env.NODE_OPTIONS ?? ""; | ||
| if (existing.includes("--max-old-space-size")) { |
There was a problem hiding this comment.
Detect underscore heap flag before appending NODE_OPTIONS
resolveNodeOptions only checks for "--max-old-space-size", so an existing NODE_OPTIONS value like --max_old_space_size=2048 is treated as missing and gets a second heap flag appended. Because Node accepts both spellings and the later one wins, users who already pinned heap via underscore syntax will be silently overridden to the auto/configured value, which can unexpectedly increase memory use.
Useful? React with 👍 / 👎.
|
This pull request has been automatically marked as stale due to inactivity. |
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Keep open for maintainer follow-up, but this PR is not merge-ready. It targets a real Gateway OOM/config gap, yet the branch conflicts with current main, copies ambient Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. So I’m closing this here because the remaining work is already tracked in the canonical issue. Review detailsBest possible solution: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. Do we have a high-confidence way to reproduce the issue? No high-confidence live OOM reproduction was run against current main. Source inspection confirms current main has no typed heap config or generated heap-only service flag, and linked Linux/macOS reports provide real crash and workaround evidence. Is this the best way to solve the issue? No, not as currently implemented. A typed heap config is a good direction, but the patch should emit a heap-only startup flag, preserve the existing Security review: Security review needs attention: The diff introduces a concrete service-startup security concern by copying ambient
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against a705a9c911bc. |
|
Strong +1 on landing this. Real-world impact from the user side:
Filed #76658 with macOS-specific repro to add evidence on top of the systemd-flavoured #52092. Happy to test a build locally on the Mac mini once the open Greptile comments (wizard blank-clear, |
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
ClawSweeper applied the proposed close for this PR.
|
Problem
Node.js defaults to a ~1.5 GB V8 heap ceiling regardless of available system RAM. On machines with 8–128 GB this leaves most memory unused and causes hard OOM aborts (
CheckIneffectiveMarkCompact→FatalProcessOutOfMemory→ SIGABRT) under heavy parallel agent workloads. The issue also affects child Node processes spawned by the gateway, which inherit no heap configuration at all.Solution
At gateway install time, automatically compute a sane heap limit (85% of
os.totalmem()) and inject it intoNODE_OPTIONS=--max-old-space-size=Nin the service environment. This propagates to child Node processes automatically via environment inheritance.Users who want a specific value can set
gateway.nodeMaxOldSpaceMbin their config. The interactive onboarding wizard shows the auto-detected value and lets them override it.Changes
src/config/types.gateway.ts— addsnodeMaxOldSpaceMb?: numbertoGatewayConfigsrc/config/zod-schema.ts— schema:z.number().int().min(256).optional()src/config/schema.labels.ts/schema.help.ts— label + help text following existing conventionssrc/daemon/service-env.ts— addsresolveDefaultNodeMaxOldSpaceMb()andresolveNodeOptions()(both exported for testing); injectsNODE_OPTIONSinbuildCommonServiceEnvironment; addsnodeMaxOldSpaceMb?param tobuildServiceEnvironmentsrc/commands/daemon-install-helpers.ts— threadsconfig?.gateway?.nodeMaxOldSpaceMbintobuildServiceEnvironmentsrc/wizard/onboarding.gateway-config.ts— adds heap prompt to non-quickstart flow, showing auto-detected value as hint, blank = auto-detectsrc/daemon/service-env.test.ts— 10 new tests covering auto-detect math, env override precedence, flag composition,buildServiceEnvironmentintegrationBehaviour details
NODE_OPTIONSNODE_OPTIONS=--max-old-space-size=<85% of RAM>gateway.nodeMaxOldSpaceMb: 6144setNODE_OPTIONS=--max-old-space-size=6144--max-old-space-sizeinNODE_OPTIONSNODE_OPTIONS<existing> --max-old-space-size=<N>Testing
59 + 32 + 20 = 111 tests, all passing.