Skip to content

feat(worker): enforce Node worker resource limits - #110

Merged
steipete merged 2 commits into
mainfrom
claude/w141-worker-resource-limits
Oct 4, 2026
Merged

steipete merged 2 commits into
mainfrom
claude/w141-worker-resource-limits

Conversation

@steipete

@steipete steipete commented Oct 4, 2026 •

Copy link
Copy Markdown

Implement Node worker resource-limit reporting and bind it to OpenClaw WebKit's per-VM managed-heap, nursery and stack controls. Previously worker.resourceLimits was missing and worker heap limits were not enforced.

The worker finishes initialization GC before installing limits. A full-GC limit breach requests termination through the existing cross-thread owner and reports ERR_WORKER_OUT_OF_MEMORY followed by exit code 1 in the parent. Normal exit and explicit termination keep their original reason. ArrayBuffer backing storage is excluded; the parent reports {} once the worker exits. Options are parsed only for Node workers, with Node's getter evaluation order. Global Web Workers do not parse or enforce these limits.

Fixed defaults and reporting-only codeRangeSizeMb are documented experimental limitations. This does not implement idle GC. Adapts oven-sh#32896; thanks @robobun. Requires OpenClaw WebKit, pinned on main by #108; upstream remains open and no duplicate PR is needed.

Before: 9/14 added resource-limit cases fail on old-engine Bun; Node 24's contract probe passes. OpenClaw custody fails 2/2 and worker memory fails at missing limit reporting; Linux Node controls pass 2/2 and 1/1. After: all 14 added cases pass; surrounding worker suites pass 281 tests with one skip and zero failures; the expanded plain fork selection passes 47/47 with zero regressions. Cross-target Rust checking passes all 12 targets. Custody passes 2/2 and memory passes 1/1. In the memory test, old Bun already passed the allocation, idle-heap and worker-reuse assertions before failing the final resource-limit assertion. This change makes that last assertion pass; it does not add a new idle-GC implementation. The integrated sample reports about 135.6 MB allocated and 1.37 MB after the existing idle collection. The full branch at the new head passes scoped Codex P2 review against its merge-base with fork main. Both exact-head native lanes pass: Linux x64 and macOS arm64. Clippy and formatting also pass on the corrected head.

Linux proof was built at 9052469a0f89e61ac37a9985cfeef0b931b7f7c7; head 3d262f621824263f6f117971e9fd980482604a4b differs from that tested source by exactly one SAFETY comment required by Clippy. A strict source comparison confirms no runtime-logic change. The fully integrated stack additionally passes all four OpenClaw consumers on one binary.

steipete and others added 2 commits October 4, 2026 14:19
Requires OpenClaw WebKit. Adapt oven-sh#32896 for per-VM managed heap limits, nursery and stack sizing, Node-only option parsing and worker-only OOM termination. Code-range sizing remains reporting-only; defaults are fixed and idle GC is outside this change.

Co-authored-by: robobun <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant