Edit Tool Crash on String Mismatch

Resolved 💬 4 comments Opened Jul 10, 2025 by emikel02 Closed Nov 30, 2025

Bug Description
Bug Summary: Claude Code CLI crashes on Edit tool string mismatch

Issue: When using the Edit tool, if the old_string parameter doesn't exactly match the file contents, Claude Code crashes with an unhandled Node.js exception instead of returning a
graceful error.

Error:
node:internal/process/promises:288
triggerUncaughtException(err, true / fromPromise /);
^

Error: String not found in file. Failed to apply edit.
at jT (file:///home/ec2-user/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1625:728)
...
Node.js v18.20.8

Expected behavior: Should return an error message like "String not found in file" without crashing the entire CLI.

Impact: Forces users to restart Claude Code session, losing context and progress.

Reproduction: Attempt to edit a file with an old_string that doesn't exactly match the file contents (whitespace, line endings, or any character difference).

Environment Info

  • Platform: linux
  • Terminal: cursor
  • Version: 1.0.48
  • Feedback ID: 668d96c3-8afb-40a5-b134-c2098cc828e3

Errors

[{"error":"RangeError [ERR_CHILD_PROCESS_STDIO_MAXBUFFER]: stdout maxBuffer length exceeded\n    at new NodeError (node:internal/errors:405:5)\n    at Socket.onChildStdout (node:child_process:490:14)\n    at Socket.emit (node:events:517:28)\n    at Socket.emit (node:domain:489:12)\n    at addChunk (node:internal/streams/readable:368:12)\n    at readableAddChunk (node:internal/streams/readable:337:11)\n    at Readable.push (node:internal/streams/readable:278:10)\n    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)","timestamp":"2025-07-10T21:27:23.260Z"},{"error":"Error: Request was aborted.\n    at dq.makeRequest (file:///home/ec2-user/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1324:3838)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","timestamp":"2025-07-10T21:27:38.331Z"},{"error":"Error: Language not supported while highlighting code, falling back to markdown: \n    at PF (file:///home/ec2-user/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1481:1184)\n    at file:///home/ec2-user/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1481:912\n    at Array.map (<anonymous>)\n    at sY (file:///home/ec2-user/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1481:903)\n    at Y_2 (file:///home/ec2-user/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1957:9730)\n    at ww (file:///home/ec2-user/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:65:19804)\n    at jP (file:///home/ec2-user/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:42569)\n    at SP (file:///home/ec2-user/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:38118)\n    at ZL (file:///home/ec2-user/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:38046)\n    at gw (file:///home/ec2-user/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:37900)","timestamp":"2025-07-10T21:28:23.919Z"},{"error":"Error: Language not supported while highlighting code, falling back to markdown: \n    at PF (file:///home/ec2-user/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1481:1184)\n    at file:///home/ec2-user/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1481:912\n    at Array.map (<anonymous>)\n    at sY (file:///home/ec2-user/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1481:903)\n    at Y_2 (file:///home/ec2-user/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1957:9730)\n    at ww (file:///home/ec2-user/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:65:19804)\n    at jP (file:///home/ec2-user/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:42569)\n    at SP (file:///home/ec2-user/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:38118)\n    at ZL (file:///home/ec2-user/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:38046)\n    at gw (file:///home/ec2-user/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:37900)","timestamp":"2025-07-10T21:29:02.030Z"}]

View original on GitHub ↗

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