[BUG] Claude Code CLI crashes with an "Invalid string length" error during normal usage.

Resolved 💬 2 comments Opened Jan 5, 2026 by ssheikhar Closed Jan 5, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Claude Code CLI crashes with an "Invalid string length" error during normal usage.

Environment:

  • OS: macOS (Darwin 23.6.0)
  • Claude Code version: 2.0.59
  • Node.js version: v23.11.0

What Should Happen?

CLI should handle large contexts gracefully, either by summarizing or providing a clear warning before hitting string length limits.

Error Messages/Logs

Error Message:
  ERROR  Invalid string length

  file:///Users/[username]/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1437:2700

  -  (file:///[...]/cli.js:1437:2700)
  -  (file:///[...]/cli.js:1634:2585)
  -  (file:///[...]/cli.js:909:5420)
  - wx (file:///[...]/cli.js:717:20240)
  - qx (file:///[...]/cli.js:717:20723)
  - Object.useState (file:///[...]/cli.js:717:27290)
  - O54.useState (file:///[...]/cli.js:158:6613)
  - yG (file:///[...]/cli.js:909:5302)
  - UN (file:///[...]/cli.js:717:19416)
  - Hu (file:///[...]/cli.js:719:3233)

Steps to Reproduce

  1. Use Claude Code in an extended conversation session
  2. Claude Code session ends abruptly

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.0.59

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

VS Code integrated terminal

Additional Information

The error appears to originate from a React useState hook in the CLI's rendering logic, suggesting the issue may be related to rendering large content rather than the API response itself.

View original on GitHub ↗

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