claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] LSP servers not loading due to race condition between LSP Manager initialization and plugin loading

Open MarjovanLier opened this issue 1 week ago • 28 comments

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?

LSP servers configured via plugins are not loaded because the LSP Manager initializes before plugin loading completes. Debug logs show the LSP Manager completing with 0 servers, then plugins loading 52ms later.

The LSP Manager finishes at 08:57:37.373Z with 0 servers. Plugins start loading at 08:57:37.425Z — 52ms too late.

Affected versions: 2.0.69 (broken), 2.0.67 (works)

Related issue: This appears to be the same async race condition pattern described in #10997 (SessionStart hooks don't execute on first run).

Reference: LSP plugin support context from https://www.reddit.com/r/ClaudeAI/comments/1otdfo9/

What Should Happen?

LSP Manager should detect and load LSP servers from all enabled plugins.

Debug logs should show:

  • Plugins load first
  • LSP Manager initializes after plugins are ready
  • LSP servers from plugins are registered (e.g., "LSP notification handlers registered successfully for all 4 server(s)")

The LSP tool should then be available with the configured language servers.

Error Messages/Logs

08:57:37.371Z [DEBUG] [LSP MANAGER] initializeLspServerManager() called
08:57:37.373Z [DEBUG] LSP notification handlers registered successfully for all 0 server(s)
...
08:57:37.425Z [DEBUG] Loading plugin phpactor-lsp from source: "./phpactor-lsp"
08:57:37.425Z [DEBUG] Loading plugin intelephense-lsp from source: "./intelephense-lsp"
08:57:37.425Z [DEBUG] Loading plugin psalm-lsp from source: "./psalm-lsp"
08:57:37.425Z [DEBUG] Loading plugin phpstan-lsp from source: "./phpstan-lsp"

Steps to Reproduce

  1. Install LSP plugins (e.g., from marketplace or local plugins with .lsp.json configuration)
  2. Set ENABLE_LSP_TOOL=true in environment
  3. Run Claude Code 2.0.69
  4. Check debug logs at ~/.claude/debug/latest
  5. Observe LSP Manager initializes with 0 servers before plugins load

Workaround: Downgrade to version 2.0.67 with claude update --version 2.0.67

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.0.67

Claude Code Version

2.0.69

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

MarjovanLier avatar Dec 14 '25 10:12 MarjovanLier

Confirming this is still present in 2.0.71.

Platform: Linux (Arch, 6.17.9-arch1-1) Terminal: tmux

Debug log shows same pattern:

14:10:55.958Z [DEBUG] [LSP MANAGER] Starting async initialization (generation 1)
14:10:55.959Z [DEBUG] LSP notification handlers registered successfully for all 0 server(s)
14:10:55.968Z [DEBUG] Loading plugin lsp from source: "./lsp"

Plugin loads correctly, lspServers config is valid, but LSP manager has already completed initialization 10ms earlier.

monneyboi avatar Dec 17 '25 14:12 monneyboi

Confirmed on 2.0.72

Platform: macOS Darwin 24.3.0 Working version: 2.0.67 ✓ Broken version: 2.0.72 ✗

Debug log (2.0.72)

14:30:15.580Z [DEBUG] LSP notification handlers registered successfully for all 0 server(s)
14:30:15.596Z [DEBUG] Loading plugin pyright-lsp from source: "./plugins/pyright-lsp"

16ms gap - LSP Manager completes before plugins load.

Verification

Tested pyright-lsp@claude-plugins-official plugin with ENABLE_LSP_TOOL=true:

Version LSP Tool Pyright Diagnostics
2.0.67 ✓ Available ✓ 3 errors detected
2.0.72 ✓ Available ✗ "No LSP server available for .py"

The LSP tool exists in 2.0.72, but no servers are registered due to the race condition.

Workaround

npx @anthropic-ai/[email protected] works as temporary solution.

MariusWilsch avatar Dec 19 '25 14:12 MariusWilsch

Follow-up: Also confirmed broken in 2.0.73 (same behavior - LSP tool exists but 'No LSP server available for file type: .py').

MariusWilsch avatar Dec 19 '25 16:12 MariusWilsch

Confirming it's still happening on 2.0.74 as well.

evanlouie avatar Dec 20 '25 00:12 evanlouie

Seems they just released LSPs officially.

  • https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md
  • https://code.claude.com/docs/en/plugins-reference#lsp-servers
  • https://code.claude.com/docs/en/plugins#add-lsp-servers-to-your-plugin

However, the race condition persists. Anyone else get it working?

MarjovanLier avatar Dec 20 '25 00:12 MarjovanLier

Additional testing evidence from 2.0.74 (comment drafted by Claude Code, posted on behalf of Marjo)

Extensive testing confirms the race condition persists in 2.0.74, including with official Anthropic LSP plugins:

Official plugins tested:

  • php-lsp@claude-plugins-official - same race condition
  • pyright-lsp@claude-plugins-official - same race condition

2.0.74 race gap measurements:

00:42:03.401Z - [LSP MANAGER] initializeLspServerManager() called
00:42:03.405Z - LSP handlers registered for 0 server(s)
00:42:03.463Z - phpactor-lsp loads (58ms LATE)
00:42:03.466Z - php-lsp loads (61ms LATE)
00:42:04.132Z - pyright-lsp loads (727ms LATE)

New in 2.0.74: LSP Plugin Recommendation feature correctly detects installed plugins but servers still don't register:

[lspRecommendation] Skipping php-lsp@claude-plugins-official (already installed)
LSP Diagnostics: Checking registry - 0 pending

Configuration changes have no effect - tested with startupTimeout, maxRestarts, restartOnCrash, and loggingConfig options. The .lsp.json files are never read due to the race condition.

Confirmed broken versions: 2.0.69, 2.0.72, 2.0.73, 2.0.74 Last working version: 2.0.67

MarjovanLier avatar Dec 20 '25 00:12 MarjovanLier

Can confirm, it's broken in 2.0.74, works in 2.0.67

xHeaven avatar Dec 20 '25 01:12 xHeaven

They added it as an official release note today and still broken lol.

MariusWilsch avatar Dec 20 '25 07:12 MariusWilsch

just confirming, broken here on 2.0.74

cat ~/.claude/debug/latest | grep -i lsp | head -n 7

2025-12-20T12:48:55.961Z [DEBUG] [LSP MANAGER] initializeLspServerManager() called
2025-12-20T12:48:55.961Z [DEBUG] [LSP MANAGER] Created manager instance, state=pending
2025-12-20T12:48:55.961Z [DEBUG] [LSP MANAGER] Starting async initialization (generation 1)
2025-12-20T12:48:55.964Z [DEBUG] LSP server manager initialized successfully
2025-12-20T12:48:55.964Z [DEBUG] LSP notification handlers registered successfully for all 0 server(s)
2025-12-20T12:48:55.967Z [DEBUG] Loading plugin rust-analyzer-lsp from source: "./plugins/rust-analyzer-lsp"
2025-12-20T12:48:55.967Z [DEBUG] Using provided version for rust-analyzer-lsp@claude-plugins-official: 1.0.0

claude --version:

2.0.74 (Claude Code)

jasoncolburne avatar Dec 20 '25 12:12 jasoncolburne

Found the issue. The LSP server manager's initialize function is essentially empty, it just returns immediately without doing anything. There's a separate function that properly loads LSP server configurations from enabled plugins, but this function is never called anywhere in the codebase.

evanlouie avatar Dec 20 '25 20:12 evanlouie

2.0.75 was released, still has the issue.

MarjovanLier avatar Dec 20 '25 20:12 MarjovanLier

why do the release notes announce the LSP function as being released if it is not working?

...
Version 2.0.74:
• Added LSP (Language Server Protocol) tool for code intelligence features like go-to-definition, find references, and hover documentation
...

rudi2k avatar Dec 20 '25 22:12 rudi2k

No LSP server available for file type .tsx
same issue!

hqman avatar Dec 21 '25 11:12 hqman

Same issue on v2.0.75 for me.

Manouchehri avatar Dec 21 '25 15:12 Manouchehri

Same issue with Go LSP (gopls) on v2.0.75

andrew-le-mfv avatar Dec 22 '25 02:12 andrew-le-mfv

Same issue.

dimsky avatar Dec 22 '25 03:12 dimsky

same issue here, wonder if there anything we can do locally to make it work

giovannirco avatar Dec 22 '25 17:12 giovannirco

@giovannirco as described in the second reply:

npx @anthropic-ai/[email protected] works as temporary solution.

I actually haven't done this, I'm just waiting - but it should work. Depending on how you installed you may need to do something slightly different? The key is pinning the version at 2.0.67.

jasoncolburne avatar Dec 22 '25 18:12 jasoncolburne

Race Condition Confirmed: https://github.com/anthropics/claude-code/issues/14803#issuecomment-3684942251

coygeek avatar Dec 23 '25 03:12 coygeek

Not working on 2.0.76 either, race condition persists.

MarjovanLier avatar Dec 23 '25 06:12 MarjovanLier

so i dove into the problem and found that this is not a race condition, it's simply not implemented afaict (at least in 2.0.74, which is what's latest in nixpkgs), the function supposedly responsible for registering the LSPs simply returns for no good reason I can find. I made a patch for this against 2.0.74, but with some tweaks it should be possible to port this to other versions, the problem is that the minified function name may change. But hopefully this gives people some idea of what to do about it instead of shouting into the void and hoping someone will actually care that the newly announced feature doesn't actually work at all...

claude-code-2.0.74-lsp-not-found-fix.patch

manveru avatar Dec 23 '25 17:12 manveru

also, i just have to say i find it silly that they release minified code, this stuff doesn't have to run in the browser, so what's the point other than to annoy people and make community contributions harder.

manveru avatar Dec 23 '25 17:12 manveru

Thanks for the insights @manveru, I wonder what happened internally that the actual code was not released with the release.

MarjovanLier avatar Dec 23 '25 18:12 MarjovanLier

Same for .cs

 No LSP server available for file type: .cs

gor-st avatar Dec 24 '25 13:12 gor-st