ERROR node memory ai_generated true

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

ID: node/err-worker-out-of-memory

Also available as: JSON · Markdown
90%Fix Rate
92%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
20 active

Root Cause

Node.js process exceeded V8 heap memory limit.

generic

Workarounds

  1. 93% success Profile with --inspect and Chrome DevTools to find the memory leak
    node --inspect app.js then open chrome://inspect to take heap snapshots

    Sources: https://nodejs.org/en/docs/guides/debugging-getting-started

  2. 85% success Increase heap limit as interim: NODE_OPTIONS=--max-old-space-size=8192
    export NODE_OPTIONS='--max-old-space-size=8192' before running

Dead Ends

Common approaches that don't work:

  1. Setting --max-old-space-size=16384 without investigating the leak 70% fail

    Delays the crash but the leak still grows unbounded

  2. Splitting the process into workers without fixing the memory issue 60% fail

    Each worker will also eventually OOM

Error Chain

Frequently confused with: