Node.js Heap Overflow in Sub-Agents During Large Codebase Processing

Resolved 💬 3 comments Opened Aug 4, 2025 by davoice-321 Closed Aug 15, 2025

Bug Description
Title: "Sub-agent memory crashes:
Node.js heap limit exceeded during
large operations"

Description:
## Issue Description
Sub-agents are crashing with
Node.js "JavaScript heap out of
memory" errors during processing
operations.

## Error Details
<--- Last few GCs --->
[254706:0x57360efe6b10] 130510 ms:
Mark-Compact 2006.3 (2090.3) ->
1995.8 (2095.8) MB
FATAL ERROR: Reached heap limit
Allocation failed - JavaScript
heap out of memory

## Environment

  • Claude Code version: [your

version]

  • OS: Linux 6.14.0-27-generic
  • Node.js processes hitting ~2GB

heap limit

  • Working on large codebase (~180K

files)

## Reproduction Steps

  1. Use sub-agents

(testing-facilitator,
debugging-efficiency-guardian,
code-quality-reviewer)

  1. Process large files or complex

operations

  1. Sub-agents crash with heap

overflow after extended use

## Impact

  • Sub-agents become unusable after

extended sessions

  • Forces terminal restarts and

context loss

  • Blocks development workflow on

large projects

## Workaround Found
export NODE_OPTIONS="--max-old-sp
ace-size=4096"

## Expected Behavior
Sub-agents should handle memory
efficiently without hitting
Node.js heap limits

  1. Additional Context to Include
  • Project size: Large codebase

with complex file structures

  • Sub-agent usage patterns: Heavy

use of testing-facilitator,
code-quality-reviewer

  • Memory consumption: Processes

reaching 2GB+ before crash

  • Frequency: Happens during

extended development sessions

Environment Info

  • Platform: linux
  • Terminal: cursor
  • Version: 1.0.67
  • Feedback ID: 9835fbf1-6bde-426d-bb40-09449d5cbf58

Errors

[{"error":"RangeError [ERR_CHILD_PROCESS_STDIO_MAXBUFFER]: stdout maxBuffer length exceeded\n    at Socket.onChildStdout (node:child_process:490:14)\n    at Socket.emit (node:events:518:28)\n    at Socket.emit (node:domain:489:12)\n    at addChunk (node:internal/streams/readable:561:12)\n    at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)\n    at Readable.push (node:internal/streams/readable:392:5)\n    at Pipe.onStreamRead (node:internal/stream_base_commons:191:23)","timestamp":"2025-08-03T17:36:06.426Z"},{"error":"Error: Agent file /home/devproduser/evol_game_project/.claude/agents/subagent-documentation-summary.md is missing required 'name' in frontmatter\n    at I58 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1923:1373)\n    at file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1923:679\n    at Array.map (<anonymous>)\n    at file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1923:622\n    at async file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1923:469\n    at async mvB (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:2569:4)\n    at async Object.prompt (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:2641:1194)\n    at async bvB (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:2536:191)\n    at async Promise.all (index 0)\n    at async Promise.all (index 0)","timestamp":"2025-08-03T17:37:09.895Z"},{"error":"MaxFileReadTokenExceededError: File content (41783 tokens) exceeds maximum allowed tokens (25000). Please use offset and limit parameters to read specific portions of the file, or use the GrepTool to search for specific content.\n    at Z68 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1513:432)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async Object.call (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1508:6368)\n    at async XK8 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:2546:10157)\n    at async xf1 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:2546:6576)\n    at async PNB (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1867:1384)\n    at async JK8 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:2546:5720)\n    at async IK8 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:2546:5205)\n    at async ES (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:2546:3667)\n    at async ZA (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:3018:2603)","timestamp":"2025-08-03T17:37:15.926Z"},{"error":"Error: Request was aborted.\n    at l71._createMessage (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1327:7955)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","timestamp":"2025-08-03T19:06:52.485Z"},{"error":"Error: Language not supported while highlighting code, falling back to markdown: \n    at CX (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1576:1184)\n   %2

Note: Error logs were truncated.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗