Intermittent crash: (r||"").toLowerCase is not a function in syntax highlighting renderer

Resolved 💬 3 comments Opened Mar 31, 2026 by zihaoxu Closed Apr 3, 2026

Description

Claude Code crashes intermittently during rendering with the error:

ERROR  (r||"").toLowerCase is not a function. (In '(r||"").toLowerCase()', '(r||"").toLowerCase' is undefined)

This has been occurring repeatedly over the past 2-3 days.

Environment

  • Claude Code version: 2.1.88
  • OS: macOS (Darwin 25.2.0)
  • Shell: zsh

Stack Trace

- B (/$bunfs/root/src/entrypoints/cli.js:1301:2087)
- Ro9 (/$bunfs/root/src/entrypoints/cli.js:2740:6419)
- render (/$bunfs/root/src/entrypoints/cli.js:2742:2254)
- ZC1 (/$bunfs/root/src/entrypoints/cli.js:2746:1456)
- <anonymous> (/$bunfs/root/src/entrypoints/cli.js:2746:2145)
- Df (/$bunfs/root/src/entrypoints/cli.js:479:20996)
- Z4 (/$bunfs/root/src/entrypoints/cli.js:479:39535)
- QH (/$bunfs/root/src/entrypoints/cli.js:479:36903)
- pH (/$bunfs/root/src/entrypoints/cli.js:479:36430)
- s7H (/$bunfs/root/src/entrypoints/cli.js:479:52626)

Analysis

The crash occurs in the bundled highlight.js language detection function B(r) which calls (r||"").toLowerCase(). The ||"" guard only handles null/undefined but not non-string types (e.g., number, object). When r is a non-string truthy value, the guard passes it through and .toLowerCase() fails because it's not a string method.

The relevant minified code path:

function B(r) {
  r = (r||"").toLowerCase()  // crashes when r is non-string truthy value
  return _[r] || _[q[r]]
}

This is similar to issue #14364 (fixed in v2.0.74) where undefined values in the rendering pipeline caused a crash.

Reproduction

  • Happens intermittently during normal Claude Code sessions
  • Appears to be triggered by specific syntax highlighting patterns in rendered output
  • Crashes the entire session, requiring restart

Expected Behavior

Claude Code should handle non-string language identifiers gracefully without crashing the session.

Suggested Fix

Replace (r||"").toLowerCase() with String(r||"").toLowerCase() or add explicit type checking before the call.

View original on GitHub ↗

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