#21295: test: guard test runner memory on local runs
scripts
maintainer
size: XS
Cluster:
Memory Management Enhancements
## Summary
- Apply a default V8 heap guard for local and non-Windows-CI test runs in `scripts/test-parallel.mjs` so `pnpm test` does not fail with default 4GB V8 OOM.
- This aligns local test execution with CI-like heap limiting behavior and reduces crashy behavior for large local suites.
- No behavior change to test selection or test content; only process-level runner options are affected.
## Testing
- node --check scripts/test-parallel.mjs
- pnpm exec vitest run src/commands/status.summary.redaction.test.ts --maxWorkers=2
## Notes
- The main `pnpm test` flow previously hit V8 OOM in this environment after long concurrent runs.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Applied a default 4GB V8 heap limit to local and non-Windows CI test runs to prevent OOM failures during large test suites. The change renames the constant from `DEFAULT_CI_MAX_OLD_SPACE_SIZE_MB` to `DEFAULT_MAX_OLD_SPACE_SIZE_MB` and makes it apply universally (local + Windows CI + non-Windows CI) instead of just non-Windows CI.
- Renamed constant reflects broader applicability
- Now returns 4GB heap limit for all environments (previously returned `null` for local/Windows CI)
- Maintains override capability via `OPENCLAW_TEST_MAX_OLD_SPACE_SIZE_MB` environment variable
- Missing heap guard in passthrough args code path (lines 336-376) - direct test invocations won't get the protection
<h3>Confidence Score: 3/5</h3>
- Safe to merge but has a logic gap in passthrough args path
- The main change correctly applies heap limiting to all test runs, but the passthrough args code path (used for direct test file invocations) doesn't apply the same heap guard, leaving a gap in OOM protection
- Pay attention to `scripts/test-parallel.mjs` - verify the passthrough args path applies heap limiting
<sub>Last reviewed commit: 7508444</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#9438: fix: auto-detect low-memory environments and prevent test OOM
by CompassHXM · 2026-02-05
80.8%
#7085: test: skip flaky workspace-paths & safe-bins tests on non-Linux/CI ...
by ThinkIbrokeIt · 2026-02-02
71.8%
#19063: CI/macOS: disable Vitest vmForks for TS tests to stop mock-state le...
by agisilaos · 2026-02-17
70.9%
#3006: fix(scripts): use local pnpm binary in run-node.mjs if global is mi...
by elliotsecops · 2026-01-27
70.6%
#23139: test: fix flaky auth tests when OPENCLAW_GATEWAY_TOKEN is present
by Imccccc · 2026-02-22
70.0%
#22897: fix(exec): guard onUpdate callback type in runtime
by Phineas1500 · 2026-02-21
69.9%
#20496: test(utils): add comprehensive unit tests for utility functions
by masifislamm · 2026-02-19
69.6%
#12804: fix(daemon): use wrapper script for pnpm global installs in service...
by odinho · 2026-02-09
69.2%
#16658: test: isolate env-dependent gateway/auth fixtures
by sauerdaniel · 2026-02-15
69.0%
#14734: test(agents): guard against stale allowAgents in existing sessions
by davidahmann · 2026-02-12
68.9%