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:

  1. q4I() returns undefined instead of null when the highlighter constructor is unavailable
  2. The code only checks for null: if(U===null)return null;
  3. When U is undefined, it passes the null check but fails when trying to instantiate new U($,A)

How to Reproduce

The crash appears to occur when:

  1. Claude is rendering code output (e.g., file contents, patches, or code blocks)
  2. The syntax highlighter initialization fails or returns undefined
  3. 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 null and undefined: if (!U || U === null) return null;
  • Or ensuring q4I() always returns null (not undefined) when unavailable
  • Or fixing the underlying initialization issue causing q4I() to return undefined

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:

  • useMemo hook in React rendering
  • Code highlighting component (f6 component based on context)
  • Likely during file write operations or patch display (HV9, DKH functions visible in stack)

Full crash log available upon request.

View original on GitHub ↗

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