[BUG] Claude Code + Visual Studio Code throwing error on diff

Resolved 💬 19 comments Opened May 22, 2025 by Rprp12 Closed Jun 2, 2025
💡 Likely answer: A maintainer (blois, collaborator) responded on this thread — see the highlighted reply below.

Environment

  • Platform (select one): Anthropic API
  • Claude CLI version: 1.0.0
  • Operating System: Windows 11
  • Terminal: Visual Studio Code + WSL

Bug Description

Everytime Claude Code wants to edit a file, it will throw the following error in the terminal - probably because of the visual studio code plugin / diff viewer. I would like to see the changes in visual studio code.

This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: String not found in file. Failed to apply edit.
at gm (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1530:518)
at S25 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1953:8393)
at J (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1953:7717)
at file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1953:7952
at f7 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:150:21374)
at gZ (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:150:40861)
at file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:150:39057
at Iy1 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:144:155632)
at Immediate.rj1 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:144:156050)
at process.processImmediate (node:internal/timers:476:21)

Steps to Reproduce

  1. Will happen on every edit / diff.

Expected Behavior

Showing diff / line changes

View original on GitHub ↗

19 Comments

blois collaborator · 1 year ago

A fix will be coming to address where this happens periodically, but it is unexpected that it happens for every edit. Can you confirm that this is indeed every edit?

Rprp12 · 1 year ago
A fix will be coming to address where this happens periodically, but it is unexpected that it happens for every edit. Can you confirm that this is indeed every edit?

I just updated to Claude Code 1.0.2 and unfortunately the issue seems to be still here. I changed about 10 CSS files, no issues, but when asking to update the README.md I am still getting the error:

Opened changes in Visual Studio Code ⧉ │
│ Save file to continue… │
│ │
│ Do you want to make this edit to README.md? │
│ ❯ 1. Yes │
│ 2. Yes, and don't ask again this session (shift+tab) │
│ 3. No, and tell Claude what to do differently (esc) │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: String not found in file. Failed to apply edit.
at mm (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1530:518)
at _25 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1953:8755)
at J (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1953:7717)
at file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:1953:7952
at f7 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:150:21374)
at gZ (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:150:40861)
at file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:150:39057
at Gy1 (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:144:155632)
at Immediate.oj1 [as _onImmediate] (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:144:156050)
at process.processImmediate (node:internal/timers:476:21)

GoldenE · 1 year ago

I am also getting this bug a lot. I will get it for both sonnet and opus, same setup as OP.

I appear to get it when its trying to do a larger diff, if i ask it to make a small change it will be fine, I believe its when it tries to do a large diff is when it fails

GoldenE · 1 year ago

Actually, i've had it happen on files now that were also short, perhaps the issue happens more often in longer context windows? I'm not sure what the cause is but it seems to be getting more frequent and is blocking me from completing large changes as i dont want to blindly accept a change

octanevz · 1 year ago

Same here, I'm getting this error message on every single edit when in VSCode (WSL2, Ubuntu 24.04). In Windows Terminal, Claude Code works just perfectly.

This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: String not found in file. Failed to apply edit.
at mm (file:///home/xxxxxxx/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1468:518)
at N25 (file:///home/xxxxxxx/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1837:9445)
at J (file:///home/xxxxxxx/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1837:8407)
at file:///home/xxxxxxx/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1837:8642
at b7 (file:///home/xxxxxxx/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:150:21374)
at hZ (file:///home/xxxxxxx/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:150:40861)
at file:///home/xxxxxxx/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:150:39057
at Qy1 (file:///home/xxxxxxx/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:144:155632)
at Immediate.sj1 [as _onImmediate] (file:///home/xxxxxxx/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:144:156050)
at process.processImmediate (node:internal/timers:485:21)

tim-basic · 1 year ago

Happening for me as well running clade code via wsl distro in vs code

This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: String not found in file. Failed to apply edit.
at mm (file:///home/unix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1468:518)
at N25 (file:///home/unix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1837:9445)
at J (file:///home/unix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1837:8407)
at file:///home/unix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1837:8642
at b7 (file:///home/unix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:150:21374)
at hZ (file:///home/unix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:150:40861)
at file:///home/unix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:150:39057
at Qy1 (file:///home/unix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:144:155632)
at Immediate.sj1 [as _onImmediate] (file:///home/unix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:144:156050)
at process.processImmediate (node:internal/timers:491:21)

tim-basic · 1 year ago

I'm going to cancel max subscription after this month ... vs code integration is so unstable on wsl

hackyon-anthropic collaborator · 1 year ago

As a status update, we're actively working to fix the WSL integration in the coming updates. Please stay tuned!

igorkofman collaborator · 1 year ago

@tim-basic what version of claude are you hitting this with (claude --version)

tim-basic · 1 year ago
@tim-basic what version of claude are you hitting this with (claude --version)

@igorkofman prints out 1.0.3 (Claude Code)

Thanks for jumping on this :)

igorkofman collaborator · 1 year ago

Please update to latest (claude update). This should be significantly less common now and we'll have a fix that full resolves it early next week.
Thanks for the report.

tim-basic · 1 year ago

Thanks - I thought I did a fresh install 2 days ago. Just updated now. Will let you know if it continues.

tim-basic · 1 year ago

Was using claude code 1.0.6 last night for 4 hours and didn't see the bug appear. @igorkofman

marty0678 · 1 year ago

It's happening on every new file for me - using Node 22.16.0 with Claude Code 1.0.33 with WSL.

tim-basic · 1 year ago

Not sure if this will work for you but I uninstalled the extension and installed from scratch and that resolved the issue for me. @marty0678

marty0678 · 1 year ago
Not sure if this will work for you but I uninstalled the extension and installed from scratch and that resolved the issue for me. @marty0678

Thanks @tim-basic but no luck. Before I posted I also set up a new nvm of the latest Node 22 LTS and installed it there and same issue.

Just tried logging out and re-installing it fresh again from that node instance and does the same thing once it tries to make a new file.

tim-basic · 1 year ago

Interesting hmm @marty0678

I'm using the following with no issues:
Node version: v22.14.0
Claude Code VS Code extension version: 1.0.33 (server version: 1.0.31)
WSL version: 2.5.9.0

oytuntez · 11 months ago

I woke up to this error with no updates in my systems through the night; been using latest Claude and Intellij.

github-actions[bot] · 11 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.