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

Prevent multiple linters running for the same URI #82

Merged
merged 2 commits into from Dec 24, 2020

Conversation

ndreas
Copy link
Contributor

@ndreas ndreas commented Dec 23, 2020

I ran into an issue while running eslint on a rather large file using eslint via efm-langserver. My setup sends diagnostics requests to the langserver whenever a change is done, and eslint takes around 4s for the largish file. With the current release of efm-langserver, this means that diagnostics requests are backed up, and requests are processed in sequence, allowing the linter to finish before processing the next request. This means that for example 3 lint requests would take 12 seconds and any diagnostics requests coming in during that time would add another 4 seconds to that.

This change spawns each linter in its own goroutine, and using context.Context a running request for a specific URI is canceled if a new request for linting arrives.

Hopefully my description makes sense!

For long running linters, there was a build up LSP requests that did not
clear until all linters had finished. Now the linters are running in a
separate goroutine with a context that is canceled whenever a new
request for the same URI comes in. This means in effect that the latest
linter instance is the one returning a result.
@mattn
Copy link
Owner

mattn commented Dec 23, 2020

Sounds good to me. Please take me a while for checking.

@mattn mattn merged commit fa5cfb7 into mattn:master Dec 24, 2020
@mattn
Copy link
Owner

mattn commented Dec 24, 2020

Thank you

@ndreas ndreas deleted the feature/kill-running-linters-on-new branch December 29, 2020 09:12
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