openclaw - 💡(How to fix) Fix Gateway OOM: Node.js exceeds default V8 heap limit with cron jobs [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#52092Fetched 2026-04-08 01:15:44
View on GitHub
Comments
2
Participants
3
Timeline
2
Reactions
1
Author
Timeline (top)
commented ×2

OpenClaw gateway process silently exits when processing cron jobs, exceeding V8's default ~1.5GB heap limit. The process vanishes without a crash log, SIGTERM, or OOM message — systemd just sees it disappear and restarts it via Restart=always.

Error Message

  1. Node process exits silently (no error in journalctl, no OOM in dmesg)

Root Cause

OpenClaw gateway process silently exits when processing cron jobs, exceeding V8's default ~1.5GB heap limit. The process vanishes without a crash log, SIGTERM, or OOM message — systemd just sees it disappear and restarts it via Restart=always.

Fix Action

Workaround

Added --max-old-space-size=4096 to the systemd ExecStart line:

ExecStart=/usr/bin/node --max-old-space-size=4096 /usr/lib/node_modules/openclaw/dist/index.js gateway --port 18789

This resolves the crash — gateway survives 1.6GB peaks and memory settles back to ~500-600MB after processing.

Code Example

systemd: openclaw-gateway.service: Consumed 42.463s CPU time, 1.7G memory peak, 0B memory swap peak.

---

ExecStart=/usr/bin/node --max-old-space-size=4096 /usr/lib/node_modules/openclaw/dist/index.js gateway --port 18789
RAW_BUFFERClick to expand / collapse

Description

OpenClaw gateway process silently exits when processing cron jobs, exceeding V8's default ~1.5GB heap limit. The process vanishes without a crash log, SIGTERM, or OOM message — systemd just sees it disappear and restarts it via Restart=always.

Environment

  • OpenClaw version: 2026.3.13 (61d171a)
  • OS: WSL2 Ubuntu 24.04 on Windows 11
  • Node: v22.22.1
  • Agent model: anthropic/claude-haiku-4-5
  • Cron jobs: 10 scheduled jobs (5 posting slots, analytics, mentions check, nightly reflection, weekly strategy, git snapshot)

Reproduction

  1. Configure ~10 cron jobs with sessionTarget: "isolated"
  2. Let the gateway go offline for several hours (WSL idle shutdown, etc.)
  3. Restart the gateway — all missed cron jobs fire simultaneously
  4. Gateway memory spikes to 1.6-1.7GB within ~20 seconds
  5. Node process exits silently (no error in journalctl, no OOM in dmesg)
  6. systemd restarts it, queued jobs fire again, repeat

Even with staggered jobs (not all firing at once), individual cron job processing peaks at 1.4-1.6GB for a single Haiku agent turn with a ~12KB SOUL.md.

Evidence

systemd: openclaw-gateway.service: Consumed 42.463s CPU time, 1.7G memory peak, 0B memory swap peak.

No kernel OOM kill in dmesg. No SIGTERM logged. Process just vanishes between journal entries.

Workaround

Added --max-old-space-size=4096 to the systemd ExecStart line:

ExecStart=/usr/bin/node --max-old-space-size=4096 /usr/lib/node_modules/openclaw/dist/index.js gateway --port 18789

This resolves the crash — gateway survives 1.6GB peaks and memory settles back to ~500-600MB after processing.

Expected Behavior

A gateway running Haiku with 10 cron jobs should not need 1.7GB of heap. Either:

  • Memory usage should be lower (agent sessions should be more memory-efficient)
  • The gateway should set a reasonable --max-old-space-size by default in its systemd unit template
  • Cron job catchup should be throttled (don't fire all missed jobs simultaneously)

Additional Context

The openclaw gateway command generates the systemd unit file automatically. The generated unit does not include any --max-old-space-size flag, leaving Node at its default ~1.5GB limit which is insufficient for normal operation with multiple cron jobs.

extent analysis

Fix Plan

To fix the issue of the OpenClaw gateway process silently exiting due to exceeding V8's default heap limit, follow these steps:

  • Increase the heap size limit: Update the ExecStart line in the systemd unit file to include the --max-old-space-size flag. For example:
ExecStart=/usr/bin/node --max-old-space-size=4096 /usr/lib/node_modules/openclaw/dist/index.js gateway --port 18789
  • Throttle cron job catchup: Modify the cron job scheduling to prevent all missed jobs from firing simultaneously. This can be achieved by:
    • Staggering job execution times
    • Implementing a queue system with a limited concurrency limit
    • Using a scheduler that supports throttling, such as node-cron with the timezone option
  • Optimize memory usage: Investigate opportunities to reduce memory usage in the Haiku agent sessions, such as:
    • Minimizing unnecessary data structures and variables
    • Using more efficient data storage and retrieval methods
    • Implementing memory caching or pooling mechanisms

Verification

To verify that the fix worked:

  • Monitor the gateway's memory usage and CPU time using journalctl and dmesg
  • Check for any error messages or crashes in the systemd logs
  • Verify that the gateway can handle multiple cron jobs without exceeding the heap size limit

Extra Tips

  • Consider setting a reasonable default --max-old-space-size value in the OpenClaw gateway's systemd unit template to prevent similar issues in the future
  • Regularly review and optimize memory usage in the Haiku agent sessions to prevent performance degradation over time
  • Explore using alternative scheduling libraries or frameworks that provide built-in support for throttling and concurrency management.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING