Crash in code highlighting: undefined is not a constructor (v2.0.71)
Resolved 💬 5 comments Opened Dec 17, 2025 by Raj-aai 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.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗