Skip to content

bug: apply_patch waits for LSPs sequentially causing big multi-file patches to hang #10965

Closed

Description

@samdickson22

Description

When apply_patch modifies multiple files, it waits for LSP diagnostics sequentially - up to 3 seconds per file. Patching 20 files can block for 60 seconds.

Code

// packages/opencode/src/tool/apply_patch.ts:235-240
for (const change of fileChanges) {
  if (change.type === "delete") continue
  const target = change.movePath ?? change.filePath
  await LSP.touchFile(target, true)  // 3s timeout, sequential!
}

Plugins

n/a

OpenCode version

1.1.39

Steps to reproduce

Run this prompt with a codex model:

Create 20 TypeScript files at the same time using bash:
- test-perf/utils1.ts through test-perf/utils20.ts
- Each exports: export function util1() { return 1 }

Then use the apply_patch tool (not sed, not individual edits) to add "// patched" as line 1 to ALL 20 files in a single patch.

After the patch tool returns, immediately say "PATCH COMPLETE" so I can time it.

watch it hang on ~ Preparing apply_patch... for 60 seconds

Screenshot and/or share link

No response

Operating System

macOS 15.6.1

Terminal

Ghostty

Activity

  1. added
    perfIndicates a performance issue or need for optimization
    on Jan 28, 2026
  2. github-actions commented on Jan 28, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  3. changed the title [-]apply_patch waits for LSPs sequentially causing big multi-file patches to hang[/-] [+]bug: apply_patch waits for LSPs sequentially causing big multi-file patches to hang[/+] on Jan 28, 2026
  4. rian-dolphin commented on Feb 4, 2026

    @rian-dolphin

    I'm also seeing hanging for apply_patch but even when I am only editing 1 file. Hangs for many minutes until I eventually interrupt it. I can see that my API request has completed with output tokens by looking in the Zen dashboard (screenshot attached).

    Maybe this warrants it's own issue given it's not related to multi-file updates. Though the update was quite a big one based on the number of output tokens.

    Image

    Also, I interrupted then used /timeline to go back to the prompt and rerun it and the same outcome. Then I interrupted and just told the model to continue, which also resulted in it hanging again. So it seemed like a repeatable issue.

  5. rian-dolphin commented on Feb 4, 2026

    @rian-dolphin

    Okay, so this was a dumb issue on my part (but also a very unclear UX that could be improved). Turns out I had added a directory to my .gitignore between prompts and then when it tried to write to the file that was now gitignored it caused the whole thing to hang indefinitely. Problem resolved when I removed the directory from the gitignore.

    Definitely unrelated to this issue but going to leave it here in case anyone happens across it in the future and might find it useful.

  6. github-actions commented on Apr 6, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingperfIndicates a performance issue or need for optimization

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions