Crash in code highlighting: undefined is not a constructor (v2.0.71)
Status Fixed / completed
Maintainer reply None cached
Activity 5 comments · opened Dec 17, 2025 · closed Dec 18, 2025
Bug Description
Claude Code crashes with a JavaScript error when attempting to render syntax-highlighted code blocks.
Error Message
ERROR undefined is not a constructor (evaluating 'new U($,A)')
/$bunfs/root/claude:1137:5029
Environment
- Version: Claude Code v2.0.71
- Platform: Linux 4.18.0-553.51.1.el8_10.cloud.0.1.x86_64
- Model: Sonnet 4.5
- Working Directory: /proj/a1/fe/rajc/a1_latest
Root Cause Analysis
Based on the crash stack trace, the issue occurs in the code highlighting component around line 1137:
M=gz.useMemo(()=>{let U=q4I();if(U===null)return null;return new U($,A)},[$,A]);
The problem:
q4I()returnsundefinedinstead ofnullwhen the highlighter constructor is unavailable- The code only checks for
null:if(U===null)return null; - When
Uisundefined, it passes the null check but fails when trying to instantiatenew U($,A)
How to Reproduce
The crash appears to occur when:
- Claude is rendering code output (e.g., file contents, patches, or code blocks)
- The syntax highlighter initialization fails or returns undefined
- Interestingly, the crash occurred while Claude was attempting to report this very bug, crashing during the rendering phase
Expected Behavior
The code should gracefully handle cases where the highlighter is unavailable by:
- Checking for both
nullandundefined:if (!U || U === null) return null; - Or ensuring
q4I()always returnsnull(notundefined) when unavailable - Or fixing the underlying initialization issue causing
q4I()to returnundefined
Suggested Fix
Change line 1137 from:
if(U===null)return null;
To:
if(!U)return null;
Or more explicitly:
if(U === null || U === undefined)return null;
Impact
This is a critical bug that causes complete crash of the CLI tool during normal operation, particularly when rendering code output or when the syntax highlighting library fails to load properly.
Additional Context
The stack trace shows the crash originates from:
useMemohook in React rendering- Code highlighting component (
f6component based on context) - Likely during file write operations or patch display (
HV9,DKHfunctions visible in stack)
Full crash log available upon request.
5 Comments
Found 2 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Also experiencing this issue.
Environment:
Error:
ERROR undefined is not a constructor (evaluating 'new G($,I,L)')
Stack trace points to the same syntax highlighting code path (useMemo in the bundled code).
Additional root cause analysis: Chalk template parser
I've been experiencing the same crash on WSL Ubuntu (v2.0.72) and did some deep investigation that may complement your findings.
The trigger: The Chalk template literal parser crashes on standalone closing braces
}in code content. Minimal reproduction:Why this matters: When Claude Code's Edit tool renders diffs, it appears to pass code through Chalk tagged templates (
chalk...``) for syntax highlighting. Any code with closing braces (PHP, JavaScript, C, Java, JSON, CSS - basically everything) triggers the parser error.Platform-specific behavior:
| Environment | Result |
|-------------|--------|
| WSL Ubuntu via Windows Terminal | ❌ Crashes |
| AlmaLinux (native Linux) | ✅ Works fine |
Same version (2.0.72), same files. The bug only manifests in certain terminal/platform combinations.
Connection to your analysis: Your finding that
q4I()returnsundefinedinstead ofnullis likely downstream of the Chalk parser failure. The chain appears to be:}→ throws errorundefinedundefined !== null)new U($,A)with undefined constructor → crashOperations affected: Only Edit tool diff rendering. Read, glob, and search operations work fine against the same files.
No workarounds found: Tested
NO_COLOR=1,FORCE_COLOR=0,TERM=dumb, VS Code integrated terminal - all still crash on WSL.This may also be related to #14180 (Unicode filename crashes) - same error signature, same platform bias toward Windows.
This should be fixed in tomorrow's scheduled release (v2.0.74). Thanks for reporting!
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.