claude-code - 💡(How to fix) Fix REPL crashes with unhandled TypeError when Write tool receives a \?\ long-path prefix on Windows

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

On Windows, invoking the Write tool with a path that starts with the long-path prefix \?\ (and likely \?\UNC\ / \.\) crashes the REPL with an unhandled TypeError from the URL constructor. The error escapes the React error boundary and unmounts the REPL.

The crash happens during tool result rendering — before any PreToolUse hook runs and before the actual write attempt — so it cannot be prevented by hooks, and it occurs even for paths that would have been denied or that the filesystem would have rejected.

Error Message

TypeError from the URL constructor. The error escapes the React error [ERROR] [reportRenderError] React boundary caught React error boundary unmounts the REPL.

Root Cause

On Windows, invoking the Write tool with a path that starts with the long-path prefix \?\ (and likely \?\UNC\ / \.\) crashes the REPL with an unhandled TypeError from the URL constructor. The error escapes the React error boundary and unmounts the REPL.

The crash happens during tool result rendering — before any PreToolUse hook runs and before the actual write attempt — so it cannot be prevented by hooks, and it occurs even for paths that would have been denied or that the filesystem would have rejected.

RAW_BUFFERClick to expand / collapse

Summary

On Windows, invoking the Write tool with a path that starts with the long-path prefix \?\ (and likely \?\UNC\ / \.\) crashes the REPL with an unhandled TypeError from the URL constructor. The error escapes the React error boundary and unmounts the REPL.

The crash happens during tool result rendering — before any PreToolUse hook runs and before the actual write attempt — so it cannot be prevented by hooks, and it occurs even for paths that would have been denied or that the filesystem would have rejected.

Reproducer

On Windows, in any session, invoke:

Write file_path="\?\C:\some\path.txt" content="anything"

(The path doesn't need to be writable — the crash is in the rendering layer.)

Expected

The path is either accepted, denied via permission, or surfaced as a "would-write" preview — the session continues.

Actual

REPL unmounts. From ~/.claude/debug/<session>.txt:

[ERROR] [reportRenderError] React boundary caught
  TypeError: "file://%3F\C:\Users\<user>\.claude\logs\test.log" cannot be parsed as a URL.
[DEBUG] Full reset (shrink->below): prevHeight=528, nextHeight=14, viewport=52
[DEBUG] [REPL:unmount] REPL unmounting

Likely cause

Looks like the tool-result preview tries to render file_path as a clickable file:// URL via new URL('file://' + encodeURIComponent(path)). The ? in the long-path prefix encodes to %3F, producing file://%3F\C:\... which is not a valid URL — the constructor throws, and nothing catches it before the React error boundary unmounts the REPL.

Environment

  • Claude Code: 2.1.142.41c (cli entrypoint)
  • OS: Windows 11 Pro 26200
  • Node: v24.3.0

Suggested fix

Either skip the URL conversion when the path string contains characters that make it an invalid URL, or wrap the URL constructor in a try/catch and fall back to plain-text rendering.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING