Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(lsp): lock out requests until init is complete #23998

Merged
merged 7 commits into from
May 29, 2024

Conversation

nayeemrmn
Copy link
Collaborator

@nayeemrmn nayeemrmn commented May 27, 2024

Previously we initialized with 'partial' config in the initialize handler and then fetched the proper per-workspace folder config in the initialized handler. The problem is textDocument/didOpen notifications arrive in between these, and it leads to diagnostics requests being started and then cancelled immediately. Also the init sequence is weirdly split between them, so for example the config tree walk doesn't take into account per-workspace folder enable settings on startup.

This unifies the init sequence into initialized and uses a token to prevent other request/notification handlers from running until it's complete. Also no longer send a diagnostics request on startup. Some tests which were subtly depending on this have been rewritten, but it all works in practice. Removes LspNpmConfigHash. It shouldn't be necessary since config changes are infrequent.

The token is a hack which is only required because the LSP spec doesn't allow workspace/configuration requests during initialize, which IMO it absolutely should. See microsoft/language-server-protocol#567 (comment).

@nayeemrmn nayeemrmn added the ci-bench put this on a PR to run the benchmarks label May 27, 2024
@nayeemrmn nayeemrmn removed the ci-bench put this on a PR to run the benchmarks label May 28, 2024
@nayeemrmn nayeemrmn requested a review from dsherret May 28, 2024 02:27
Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I kind of wonder if this will cause some deadlocks for a badly implemented language client though, but probably nobody has that bad of an implementation.

cli/lsp/language_server.rs Outdated Show resolved Hide resolved
@nayeemrmn nayeemrmn merged commit 14a7460 into denoland:main May 29, 2024
17 checks passed
@nayeemrmn nayeemrmn deleted the lsp-init-dedup branch May 29, 2024 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants