[BUG] Claude Code CLI: TypeError - codePointAt() Called on Undefined Segment
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?
Working with claude code and giving it significant (~1000 words) pasted text. Got the following error causing segmentation fault and core dumped
claude --version => 1.0.120 (Claude Code)
What Should Happen?
Normal processing of the reference text pasted and proceed with task
Error Messages/Logs
TypeError: Cannot read properties of undefined (reading 'codePointAt')
at C7 (file:///root/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:786:28790)
at $N9 (file:///root/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:788:3598)
at file:///root/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:794:13
at Array.map (<anonymous>)
at ia (file:///root/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:794:4)
at qN9 (file:///root/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:795:2485)
at EN9 (file:///root/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:795:4415)
at Object.measure (file:///root/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:785:5143)
at O0 (file:///root/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:786:20020)
at t (file:///root/.nvm/versions/node/v22.17.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:786:19504)
Steps to Reproduce
not sure, but happens everytime I run anything with long pasted document, for instance copying the file_API page docs from docs.claude.com
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
1.0.120 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
VS Code integrated terminal
Additional Information
This is a JavaScript error from the @anthropic-ai/claude-code CLI tool. Let me break down what happened:
The Error
Location: The error occurs in the C7 function at line 786 when trying to call .codePointAt() on undefined
Root Cause: The code is attempting to get the Unicode code point of a character in a string, but the character (referenced as I in the segment) is undefined.
What Likely Went Wrong
Looking at the stack trace and the code context visible in your error, this appears to be in the text width calculation logic used for rendering CLI output. The function C7 (likely calculating character/string width) is:
Segmenting text using Intl.Segmenter
For each segment, trying to get the first code point
The segment is unexpectedly undefined instead of a string
This could happen if:
The input string contains unusual Unicode sequences that the segmenter can't handle properly
There's a null/undefined value being passed through the text processing pipeline
The string splitting/segmentation is producing empty or invalid segments
Immediate Context
The error occurred while the Claude Code CLI was trying to measure or render some text output, possibly while displaying a response or formatting terminal output.
Suggested Fix
This looks like a bug in the Claude Code CLI tool itself. You should:
Report this to Anthropic as it's an internal tool bug
As a workaround, try updating to the latest version: npm update -g @anthropic-ai/claude-code
If the issue persists, check what command or input triggered this error and avoid that specific scenario
The error suggests the CLI needs better null-checking before calling .codePointAt() on segment values.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗