fix(diagnostics): wait for publishDiagnostics instead of sleeping 3s#131
Open
STRd6 wants to merge 1 commit into
Open
fix(diagnostics): wait for publishDiagnostics instead of sleeping 3s#131STRd6 wants to merge 1 commit into
STRd6 wants to merge 1 commit into
Conversation
…ping 3s The diagnostics tool slept a hardcoded 3s after open_document then fell back to a textDocument/diagnostic pull request. Servers that only support push-mode diagnostics (e.g. Civet's LSP) returned -32601, which was logged as an error even though the publishDiagnostics cache was already populated correctly. This change: - Adds Client.WaitForDiagnostics(uri, timeout, settle) which blocks until the LSP publishes diagnostics for the URI (signaled by the publishDiagnostics handler), with a settle window for follow-up republishes. - Replaces the 3s sleep in GetDiagnosticsForFile with that wait. - Demotes the pull-mode failure from Error to Debug — push-only servers are common (Civet, several others) and the pull is an optional optimization, not a requirement. Measured against civet-lsp: cold call 3008ms -> 414ms, warm 3002ms -> 0ms.
STRd6
pushed a commit
to STRd6/mcp-language-server
that referenced
this pull request
May 14, 2026
Upstream's last commit on isaacphi/main is 2025-06-03 — ~11 months of inactivity. PR isaacphi#131 has sat in their review queue unmerged since the start of this session. The expected-upstream-merge path that justified keeping the original module path no longer applies in practice. Renames the module to github.com/STRd6/mcp-language-server across: - go.mod - every internal import (~80 .go files) - the integration-test template workspaces' go.mod - the snapshots that capture gopls hover/definition output (which embeds package paths) - README install instructions go install github.com/STRd6/mcp-language-server@latest now works. Anyone using the previous install path (go install github.com/isaacphi/...) keeps getting upstream's 2025-06-03 cut; they will need to switch binaries to pick up this fork's changes. The import-path inside go.mod is the only signal a Go compiler uses to identify a module, so the GoDoc badge in the README is dropped since pkg.go.dev/STRd6/... isn't indexed by GoDoc the same way. The other three badges (CI, Go report card, go-version) already pointed at STRd6 in the previous README refresh. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
diagnosticstool currently sleeps a hardcodedtime.Sleep(time.Second * 3)afterOpenFilethen callstextDocument/diagnostic(pull-mode). Two problems:// TODO: wait for notification.[ERROR][tools] Failed to get diagnostics: ... Unhandled method textDocument/diagnosticeven though thepublishDiagnosticscache was populated correctly. This is the exact symptom reported in Unreliable diagnostics for typescript-server #60.Fix
Client.WaitForDiagnostics(uri, timeout, settle)which blocks untiltextDocument/publishDiagnosticsarrives for the URI (signaled from the existing handler), with a settle window for follow-up republishes that some servers send after a project-wide rescan.GetDiagnosticsForFilecallsWaitForDiagnostics(ctx, uri, 3*time.Second, 150*time.Millisecond)instead of the unconditional sleep. The 3s upper bound preserves the previous worst case.textDocument/diagnosticpull call is kept (still useful for true pull-mode servers like gopls) but the unavailable-method log goes from Error to Debug — push-only servers are common and the cache is already fresh.No changes to public tool surface or arguments. Pull-mode LSPs see no behavioral change beyond faster return after publish.
Impact
Measured against a push-only LSP (Civet language server) with a file containing two TS type errors:
diagnosticscolddiagnosticswarmCloses #60.
Test plan
🤖 Generated with Claude Code