perf(lsp): lock out requests until init is complete #23998
Merged
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.
Previously we initialized with 'partial' config in the
initialize
handler and then fetched the proper per-workspace folder config in theinitialized
handler. The problem istextDocument/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. RemovesLspNpmConfigHash
. 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 duringinitialize
, which IMO it absolutely should. See microsoft/language-server-protocol#567 (comment).