[BUG] RangeError: Invalid array length

Resolved 💬 5 comments Opened Nov 22, 2025 by ken-willis Closed Jan 23, 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?

Issue

11/23/2025 Update:
Full error log was not showing before. Latest crash showed full error upon resizing window. ### Error Messages/Logs below has been updated with full error message.

Initial Report:
Claude Code crashes with an unhandled promise rejection during the rendering phase. Two distinct crashes occurred in the same session within 7 minutes:

RangeError: Invalid array length
    at OzA.get (cli.js:843:8122)
    at PiA.renderer (cli.js:845:1545)
Crash Pattern

Crash 1: During Plan Mode Presentation

  • When: 6:53 AM (Nov 22, 2025) - 2 minutes after user requested refactor
  • Context: Plan agent completed research, preparing to present ExitPlanMode with refactoring plan
  • State: Minimal - no file edits yet, only plan data loaded
  • Recovery: User executed /resume command, session recovered
  • User confirmation: "You crashed again" (line 294 in transcript)
  • Outcome: Session continued normally, plan presented successfully, user approved

Crash 2: During Multi-File TODO ImplementationPrimary crash being reported

  • When: 7:01 AM (Nov 22, 2025) - 7 minutes after first crash
  • Context: Executing 10-item TODO list, working on 8th item (CLAUDE.md)
  • State: 7+ files successfully edited, 13+ files tracked in file history
  • Preceding operations:
  • README.md: Edited successfully (18 path replacements, ~21KB file)
  • Tests updated, multiple documentation files modified
  • TODO updated: README marked "completed", CLAUDE.md marked "in_progress"
  • Last logged operation: Grep command on CLAUDE.md (line 369 in transcript)
  • Recovery: None - session terminated
Context & Symptoms

Common to all crashes:

  • Identical error: RangeError: Invalid array length in rendering layer
  • No error logged in debug file - sessions end abruptly
  • Rendering layer failure (OzA.get → PiA.renderer)

Crash 2 Context:

  • Working through TODO list editing 13 files (+22 -410 lines total)
  • Files are small (CLAUDE.md is 8KB, README.md is 21KB)
  • Edit summary was displaying: "13 files +22 -410"
  • Occurred during TODO list operation
  • Show 30-60 seconds of severe CLI performance degradation before crash (3-10 second input lag, keystrokes appearing in bursts)

Crash 3 Context:

Active Operation:

  • Editing Write-OptimizedControl.ps1 to remove -Overwrite parameter
  • Todo list had 4 items, transitioning task 3 from "in_progress" to "completed"
  • Multi-file editing session with previous successful todo updates

Todo List State at Crash:
[
{"content": "Remove existing file check logic", "status": "completed"},
{"content": "Add directory cleanup logic", "status": "completed"},
{"content": "Remove -Overwrite parameter", "status": "in_progress"},
{"content": "Update documentation", "status": "pending"}
]

What Should Happen?

Expected Behavior
  1. Promise rejection should be caught with user-friendly error message
  2. Renderer should handle multi-file diffs without array overflow (even with small files)
  3. Performance should remain responsive during sequential file edits
  4. If diff rendering encounters an error, gracefully degrade (e.g., "13 files changed, unable to display full diff")

Error Messages/Logs

Crash 2:

>  
────────────────────────────────────────────────────────────────────────────────
  13 files +22 -410
  ⏵⏵ accept edits on (shift+tab to cycle)
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
RangeError: Invalid array length
    at OzA.get (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:843:8122)
    at PiA.renderer (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:845:1545)
    at PiA.onRender (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:864:6669)
    at resetAfterCommit (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:840:317)
    at w4 (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:744:39502)
    at EH (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:744:38875)
    at E$ (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:744:35440)
    at u2 (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:742:4841)
    at k5 (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:744:32483)
    at gW (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:742:24933)
RangeError: Invalid array length
    at OzA.get (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:843:8122)
    at PiA.renderer (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:845:1545)
    at PiA.onRender (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:864:6669)
    at Z4B.B4B.signal (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:738:2509)
    at W (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:738:1916)
    at X (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:738:1956)
    at Timeout._onTimeout (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:738:2031)
    at listOnTimeout (node:internal/timers:608:17)
    at process.processTimers (node:internal/timers:543:7)

**Environment Info**
- Platform: win32
- Terminal: vscode
- Version: 2.0.50
- Feedback ID: 0df2960c-8acf-4499-bdda-e4b4886ccc3e

**Errors**

[]

Crash 3:

``` shell
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
RangeError: Invalid array length
at OzA.get (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:843:8122)
at PiA.renderer (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:845:1545)
at PiA.onRender (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:864:6669)
at resetAfterCommit (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:840:317)
at w4 (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:744:39502)
at EH (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:744:38875)
at E$ (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:744:35440)
at u2 (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:742:4841)
at k5 (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:744:32483)
at gW (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:742:24933)
RangeError: Invalid array length
at OzA.get (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:843:8122)
at PiA.renderer (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:845:1545)
at PiA.onRender (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:864:6669)
at PiA.V [as scheduleRender] (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:738:2642)
at WriteStream.handleResize (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:864:6415)
at WriteStream.emit (node:events:508:28)
at WriteStream.emit (node:domain:489:12)
at WriteStream._refreshSize (node:tty:143:10)
at process.refreshStdoutOnSigWinch (node:internal/bootstrap/switches/is_main_thread:138:10)
at process.emit (node:events:520:35)
Error: Minified React error #327; visit https://reactjs.org/docs/error-decoder.html?invariant=327 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
at E$ (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:744:35163)
at u2 (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:742:4841)
at Sx1 (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:738:5639)
at Immediate.Lx1 (file:///C:/Users/username/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:738:6058)
at process.processImmediate (node:internal/timers:505:21)

Environment Info

  • Platform: win32
  • Terminal: vscode
  • Version: 2.0.50
  • Feedback ID: 707b1204-caf1-44f4-9aad-5f7baaa7f56b

Errors

[]


### Steps to Reproduce

**Scenario 1: Crash during Plan mode presentation (reproduced)**
1. Start Claude Code session
2. Request complex refactor involving 10+ files (e.g., "move script, update paths, add progress bars")
3. Claude invokes Plan agent to research changes
4. Plan agent completes, Claude prepares to present ExitPlanMode
5. **Crash occurs** - RangeError: Invalid array length
6. Use `/resume` to recover
7. Session continues normally

**Scenario 2: Crash during multi-file TODO implementation (reproduced)**
1. Continue from recovered session (or start fresh and skip to step 3)
2. Present and approve plan with 10+ TODO items across 13+ files
3. Claude creates TODO list and begins implementation
4. Successfully complete 7+ file edits (e.g., progress bars, path updates, documentation changes)
5. Work through TODO list sequentially
6. Observe performance degradation (3-10 second keyboard input lag) starting 30-60 seconds before crash
7. After completing one file edit (README.md), Claude marks it complete and moves to next file (CLAUDE.md)
8. **Crash occurs** during transition - RangeError: Invalid array length

**Consistency:** Both crashes reproduced in same session within 7 minutes. Both recoverable with `/resume`. Additional crashes intermittent.

### Claude Model

Sonnet (default)

### Is this a regression?

Yes, this worked in a previous version

### Last Working Version

2.0.49

### Claude Code Version

2.0.50 (Claude Code)

### Platform

Anthropic API

### Operating System

Windows

### Terminal/Shell

PowerShell

### Additional Information

Feedback ID: 0df2960c-8acf-4499-bdda-e4b4886ccc3e
Feedback ID: 707b1204-caf1-44f4-9aad-5f7baaa7f56b

#### NPM Version

npm --version
11.6.0


#### Crash 2 Timeline Analysis

File timestamp analysis reveals crash occurred at a specific transition point:
- **User prompt submitted:** 6:51:52 AM - timestamp 1763815912563
- **README.md modified:** 7:00:45 AM ✅ Successfully edited and saved (marked "completed" in TODO)
- **CLAUDE.md last modified:** 5:50 PM Nov 21 ❌ Marked "in_progress" in TODO but NEVER MODIFIED
- **CHANGELOG.md last modified:** 6:35 PM Nov 21 ❌ Never reached (stayed "pending")

**Crash occurred during rendering of edit summary after completing README.md and before writing CLAUDE.md changes.**

#### Crash 2 User Investigation Findings

**1. Crash can occur at multiple points - not just after extensive operations:**
- Crash 1: Minimal state (plan presentation only)
- Crash 2: After accumulating state from 7+ file edits

**2. Observations about failure conditions:**
- Failures observed with minimal operations (plan display) and after multiple operations
- May become more frequent as operations accumulate (observed twice in 7 minutes)
- Small files rule out file size as direct cause

**3. Observable patterns:**
- Both crashes recoverable with `/resume`
- Performance degradation (3-5 second input lag from keystrokes to terminal) observed before both crashes
- Both crashes occurred at transition points (plan presentation, between file edits)

#### Crash 2 Claude Provided Technical Analysis

The error originates in the rendering layer (PiA.renderer) attempting to display edit summaries.

**Code Analysis (cli.js):**

The error occurs in `OzA.get()` which creates screen buffer arrays:
- `Array(this.height)` and `Array(this.width)`
- Dimensions computed by Yoga layout engine from React component tree
- Also creates `Array(width * height)` for cell buffer

Any of these allocations could fail if width/height values are invalid (negative, NaN, or multiplication exceeds 2^32-1).

**The "Invalid array length" with small files (8KB) suggests this may not be legitimate resource exhaustion.**

**Potential areas for investigation:**
- Yoga layout engine width/height calculations for edit summary widget
- Screen buffer array allocation (width * height multiplication)
- Dimension calculations in diff display logic
- State management across sequential operations

#### Crash 2 Debug Log Analysis

The debug log shows normal operation through **13:01:09 UTC (7:01:09 AM local)**, then abruptly ends with no error entry.

**Observed pattern:** Both crashes show identical behavior - normal debug logs, then abrupt termination with no error entry. The RangeError appears in CLI output but NOT in debug logs.

#### Crash 3 Claude Provided Analysis

**Suspected Root Cause:**
  - React renderer attempting to create array with invalid length when rendering todo list
  - Possible issue with terminal resize event (WriteStream._refreshSize, refreshStdoutOnSigWinch in stack)
  - May be related to todo list item rendering or progress tracking display

**React Error 327:**
  According to React docs, this typically indicates: "Maximum update depth exceeded" or array/collection rendering issue

#### Crash 3 Reproduction Notes

**Difficult to reproduce reliably because:**
  - Appears to be timing-related or terminal state-related
  - May be related to terminal window resizing during rendering
  - Stack shows handleResize and refreshStdoutOnSigWinch events

**Possible triggers:**
  - Terminal window resize during todo update
  - Large number of verbose output lines + todo update simultaneously
  - Rapid state transitions in todo list

#### File Context
- **CLAUDE.md:** 8KB (reported by Windows as 12KB on disk) - NOT a large file
- **README.md:** Successfully edited before crash 2 (18 path replacements, ~21KB file)
- **Total files being edited:** 13 files tracked
- **Total line changes:** +22 -410 lines
- **Multiple sequential edits** to different files as part of TODO list execution

#### File Attachments

**Essential files (sanitized):**
1. **Debug log:** [f20a6913-0aac-4642-b88e-bb6b87e9edc2.txt](https://github.com/user-attachments/files/23690263/f20a6913-0aac-4642-b88e-bb6b87e9edc2.txt) - Full session debug log
2. **TODO state:** [f20a6913-0aac-4642-b88e-bb6b87e9edc2-agent-f20a6913-0aac-4642-b88e-bb6b87e9edc2.json](https://github.com/user-attachments/files/23689294/f20a6913-0aac-4642-b88e-bb6b87e9edc2-agent-f20a6913-0aac-4642-b88e-bb6b87e9edc2.json) - TODO list state at crash

View original on GitHub ↗

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