Skip to content

Ensure LSP requests don't use stale data #57

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

Merged
merged 1 commit into from
Mar 9, 2021

Conversation

dfreeman
Copy link
Member

@dfreeman dfreeman commented Mar 9, 2021

Another bugfix for something I ran into working on typesafe reexports. This struck particularly frequently with autosuggest (for reasons that will become clear) but was actually a potential problem for any LSP request coming in immediately after an editor change.

Prior to this change, requests to the language server would use the most recently calculated transform information about open files without triggering a recalculation themselves. This nearly always worked, because following any sequence of changes with a brief cooldown, we'd interrogate the TS language service for diagnostics, which would trigger a fresh transformation of any changed modules. If a request came in during that cooldown period, though, they would operate against the version of the workspace from before the change, potentially leading to incorrect results.

This change ensures all operations go through a flow that validates the document hasn't changed since the last transform, rather than only attempts to read the file contents.

@dfreeman dfreeman added the bug Something isn't working label Mar 9, 2021
@dfreeman dfreeman merged commit 1c005c4 into master Mar 9, 2021
@dfreeman dfreeman deleted the cache-invalidation-for-autosuggest branch March 10, 2021 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant