Skip to content

LSP server spawn hangs indefinitely when download/build fails, blocking all file tools #20824

Closed as not planned

Description

@rareboe

Bug Description

When an LSP server's spawn() function downloads or builds external resources (e.g., ESLint fetching vscode-eslint from GitHub, ElixirLS building from source), the operation has no timeout. If the network is blocked, slow, or the build hangs, the spawn promise stays pending forever.

This promise is stored in the spawning Map inside getClients() (lsp/index.ts). Every subsequent call to getClients() for the same server extension awaits this inflight promise indefinitely:

const inflight = s.spawning.get(root + server.id)
if (inflight) {
  const client = await inflight  // blocks forever
}

Since getClients() is called by touchFile(), which runs after every Write and Edit tool execution, all file-modifying tools hang in "running" state permanently.

Steps to Reproduce

  1. Run OpenCode in a container environment where outbound access to GitHub is blocked or extremely slow
  2. Have a project with eslint in node_modules (triggers ESLint LSP auto-spawn)
  3. ESLint LSP spawn attempts fetch("https://github.com/microsoft/vscode-eslint/archive/refs/heads/main.zip") — this never completes
  4. Use the Write or Edit tool on any file
  5. The tool writes the file successfully but never returns completion — stuck at LSP.touchFile() → getClients() → await inflight

Observed Behavior

  • Log shows spawning eslint server and downloading and building VS Code ESLint server but never installed VS Code ESLint server or any error
  • The opencode/bin/ directory remains empty (download never completed)
  • All subsequent Write/Edit tool calls hang indefinitely
  • The tool status shows "running" forever in the UI
  • The file content IS written successfully — the hang occurs in the post-write LSP diagnostics step

Expected Behavior

The spawn should time out after a reasonable period, mark the server as broken, and allow subsequent tool calls to proceed without LSP diagnostics for that server.

Affected LSP Servers

All servers that download or build external resources: ESLint, ElixirLS, Zls, Gopls, CSharp, FSharp, Rubocop, Clangd, JDTLS, Kotlin-LS, Lua-LS, Terraform-LS, Texlab, Tinymist.

Environment

  • OpenCode running in a Fly.io container
  • GitHub access intermittently blocked by network
  • Project has eslint as a dependency

Activity

  1. added
    core
    perf
    on Apr 3, 2026
  2. github-actions commented on Apr 3, 2026

    @github-actions
    Contributor

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

    If these don't fully cover your specific scenario (no-timeout on the initial download/build phase), it may be worth referencing them in this issue for context.

  3. removed
    perf
    core
    on May 3, 2026
  4. chrythjin commented on May 17, 2026

    @chrythjin

    Repro: Windows — TUI zombie after read/edit + TypeScript LSP touchFile (1.15.3, Bun)

    Related: #125, #20824, #10965, #20835

    Environment

    Item Value
    OS Windows 11 (build 26200)
    OpenCode 1.15.3 ([email protected], Bun 1.3.13 embedded in opencode.exe)
    Node (global CLI) 22.22.0
    typescript-language-server 5.1.3 (global npm)
    Project TypeScript monorepo — work under a shared/ subfolder (not repo root)
    LSP config Only typescript-language-server enabled; biome and other LSPs explicitly disabled
    Env OPENCODE_EXPERIMENTAL_LSP_DIAGNOSTICS_TIMEOUT_MS=15000 (when set; freeze still occurs)
    Plugins oh-my-openagent, @plannotator/opencode, @cortexkit/opencode-magic-context (no Historian child sessions during freeze)

    Minimal opencode.json LSP block:

    "lsp": {
      "typescript": {
        "command": ["typescript-language-server", "--stdio"],
        "extensions": [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts"]
      },
      "biome": { "disabled": true, "extensions": [] }
    }

    Symptom

    • TUI still renders; keyboard input dead (“zombie TUI”).
    • opencode.exe process shows Responding: True (~300–800 MB WS).
    • Log file stops writing for 8+ minutes after last LSP line.
    • Ctrl+C often does not recover; Stop-Process -Force required.
    • Setting "lsp": false in global config stops the freezes (local workaround).

    Steps to reproduce

    1. Open a TypeScript monorepo with a shared/package.json and .ts sources under shared/src/.
    2. Start OpenCode TUI (opencode).
    3. Run a parent session with parallel subagent work (e.g. oh-my-openagent /start-work → spawns a subagent on openai-oauth/gpt-5.4-mini-xhigh).
    4. Subagent uses read on multiple files under shared/src/ in quick succession, or edit on a .ts file there (format runs after edit).

    Observed behavior (two variants, same hang point)

    Variant A — read (3 files):

    permission=read pattern=shared\src\<file-a>.ts  allow
    permission=read pattern=shared\src\<file-b>.ts  allow
    permission=read pattern=shared\src\<file-c>.ts  allow
    lsp file=...\shared\src\<file-b>.ts touching file
    lsp serverID=typescript root=...\<monorepo>\shared spawned lsp server
    lsp.client serverID=typescript sending initialize
    lsp file=...\shared\src\<file-a>.ts touching file
    lsp file=...\shared\src\<file-c>.ts touching file
    lsp.client serverID=typescript initialized
    ← NO FURTHER LOG LINES (8+ min)
    

    Variant B — edit + format:

    permission=edit pattern=shared/src/<file-a>.ts allow
    format file=...\shared\src\<file-a>.ts formatting
    lsp file=...\shared\src\<file-a>.ts touching file
    lsp serverID=typescript root=...\<monorepo>\shared spawned lsp server
    lsp.client serverID=typescript initialized
    ← NO FURTHER LOG LINES (8+ min)
    

    Expected

    After lsp.client … initialized, session should continue (session.prompt next step, tool completion, or diagnostics timeout) without blocking the TUI event loop.

    Actual

    Process hangs indefinitely after initialized; no ERROR line in log.

    Workaround

    • Global "lsp": false or "typescript": { "disabled": true } → no freeze on same workflow.
    • Re-enabling TypeScript LSP → freeze returns.

    Hypothesis

    Matches this issue: post-tool LSP.touchFile() → getClients() awaits spawn/diagnostics without effective timeout on Windows + Bun, blocking the main loop after initialize completes.

    Possibly aggravated by:

    Happy to provide redacted full log tail or test with opencode scrap <file.ts> --print-logs if useful.

  5. github-actions commented on Jul 17, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 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

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions