Maximum call stack size exceeded during high-context message processing

Resolved 💬 2 comments Opened Jan 14, 2026 by fmaa-admin Closed Feb 28, 2026

Summary

Claude Code CLI crashes with RangeError: Maximum call stack size exceeded during high-context scenarios, specifically in message normalization or tool schema building.

Environment

  • Claude Code version: Latest (as of 2026-01-14)
  • Node.js version: v24.12.0
  • Platform: Linux (WSL2)
  • Claude Code location: /usr/local/share/nvm/versions/node/v24.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js

Error Details

Exception in PromiseRejectCallback:
file:///usr/local/share/nvm/versions/node/v24.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:4474
[minified code snippet]

RangeError: Maximum call stack size exceeded

Exception in PromiseRejectCallback:
file:///usr/local/share/nvm/versions/node/v24.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1077
[minified code snippet]

RangeError: Maximum call stack size exceeded

Context at Time of Crash

  • Context usage: Statusline showed 84% context consumption
  • Statusline inconsistency: Also displayed "Context low (0% remaining)" simultaneously
  • Model: Claude Opus 4.5
  • Activity: Normal conversation, no unusual tool calls in progress

Suspected Cause

Based on the stack trace snippets visible in the minified code, the recursion appears to be happening in:

  1. Message normalization (query_message_normalization_start)
  2. Tool schema building (query_tool_schema_build_start)
  3. Recursive input processing - A function that processes tool inputs recursively

The crash likely occurs when processing deeply nested tool call results or message content structures.

Reproduction

Unable to reliably reproduce. The crash occurred during normal conversation flow at high context usage (84%). Factors that may contribute:

  • High accumulated context (200K token model at 84% = ~168K tokens)
  • Complex/nested tool call results in conversation history
  • Plugins with many MCP tools (several MCP servers configured)
  • Multiple hook scripts running on various events

Additional Observations

  1. Statusline display bug: The statusline showed both "84%" and "0% remaining" which is contradictory
  2. No graceful degradation: The crash was unrecoverable; required starting new session
  3. No warning before crash: No indication that the recursive processing was approaching limits

Expected Behavior

  • Claude Code should handle high-context scenarios gracefully
  • If message/tool processing becomes too deep, should fail with a clear error rather than stack overflow
  • Statusline should show consistent context percentage

Suggested Fix Areas

  1. Add iteration depth limits in recursive message/tool processing
  2. Use iterative approaches instead of recursion for deeply nested structures
  3. Add try-catch around recursive processing with meaningful error messages
  4. Fix statusline display inconsistency (showing 84% and 0% remaining simultaneously)

Workaround

Run /compact before reaching high context levels to reduce accumulated message complexity.

View original on GitHub ↗

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