[BUG] Repeated edits to large HTML file silently break script execution
Resolved 💬 4 comments Opened May 3, 2026 by sergiopascali-afk Closed May 7, 2026
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Setup:
- File: ~25k-line single-file HTML (index.html, ~5MB)
- Working directory served via browser-sync proxy (port 3009)
- Multi-step session adding a new floating UI panel (~100 lines of JS) inside an IIFE
Pattern observed:
After several rounds of Edit tool calls inserting JS into the file, the page goes blank / scripts fail to execute, even though:
- git diff shows clean, well-formed diffs
- The inserted code looks syntactically valid in isolation
- Reverting via git checkout HEAD -- index.html immediately restores the working state
What I'd want investigated:
- Are large Edit operations on multi-MB inline-script files reliably preserving file integrity? (Encoding, line endings, hidden whitespace?)
- Could partial edits land mid-string when the old_string matches across a script boundary?
- Is there a way for the agent to verify the script parses (via node --check or similar) after each edit on this kind of file?
Repro: Iteratively add ~100 lines of JS to a ~25k-line <script> block in a single HTML file via the Edit tool. Reload the served page after each edit;
observe whether scripts still execute.
What Should Happen?
Finisht the task and give me the changes requested as intended.
Error Messages/Logs
Steps to Reproduce
html css js runnign edits on the project and it breaks.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
Claude Code 2.1.126.
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗