Skip to content

fix(bridge): translator lock held across 30s pull_diagnostics blocks all concurrent MCP tools #159

Description

@bug-ops

Description

handle_diagnostics in Hybrid mode acquires Arc<Mutex<Translator>> and holds it for the entire duration of a pull_diagnostics LSP request (30 s timeout). Every other MCP tool handler acquires the same lock. Under concurrent tool calls — e.g. get_hover + get_diagnostics + get_references — the non-diagnostics requests stall for up to 30 seconds waiting for the lock to release.

Additionally, the new ensure_open stat-on-access adds 2–3 syscalls (stat + possible read + re-stat) under the same lock per tool call, compounding under concurrent usage.

Reproduction Steps

  1. Configure mcpls with a Hybrid diagnostics mode and a slow or busy LSP server
  2. Send concurrent MCP requests: get_hover and get_diagnostics simultaneously
  3. Observe: get_hover stalls until pull_diagnostics times out (up to 30 s)

Expected Behavior

Non-diagnostics tool calls should not be blocked by an in-flight get_diagnostics request.

Actual Behavior

All MCP tool calls share a single Translator mutex. handle_diagnostics holds it across the full LSP round-trip.

Affected Code

  • crates/mcpls-core/src/mcp/server.rs:59 — all handlers acquire translator.lock().await
  • crates/mcpls-core/src/bridge/translator.rspull_diagnostics awaits 30 s under lock

Fix Direction

Extract per-language-server LSP I/O behind per-server locks (or per-request channels) so the global translator lock is only held for in-memory state mutations, not across LSP network round-trips.

Environment

  • Affects all LSP servers in Hybrid diagnostics mode
  • Severity increases with number of concurrent MCP clients / tools

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium: suboptimal behavior, minor inconsistencybugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions