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

Race condition in LanguageServerWrapper on exception in StreamConnectionProvider.start() #804

Closed
ChristophKaser opened this issue Sep 13, 2023 · 2 comments · Fixed by #808

Comments

@ChristophKaser
Copy link
Contributor

Hi everyone,

I have observed the following behavior when I use a custom StreamConnectionProvider that tries to contact a remote language server using websockets: When the server is down, eventually lsp4e stops trying to recreate the language server connection. This is caused by an exception thrown in StreamConnectionProvider.start() that causes the following race condition:

Sometimes, the initializeFuture gets assigned the failed future from line 259 after the stop-Method has been called in line 326. When this happens, LanguageServerWrapper.start() does not start a new language server any more, because it only checks for initializeFuture == null in

.

One possible solution might be to amend line 256 with something like && !this.initializeFuture.isCompletedExceptionally().

@mickaelistria
Copy link
Contributor

Thanks for the PR. Feel free to submit a PR and we'll review it.
If you can manage to reproduce this case with a unit test as part of the PR, it would be great!

@ChristophKaser
Copy link
Contributor Author

ChristophKaser commented Sep 14, 2023

I created a PR with a unit test that reproduces the problem reliably for me and a fix.

rubenporras pushed a commit that referenced this issue Sep 18, 2023
…808)

* Test exception in ConnectionStreamProvider.start()

When ConnectionStreamProvider.start() throws an IOException, a race condition can occur that causes further attempts to start the language server to be ignored (issue 804)

* Fix race condition in LanguageServerWrapper

Fixes #804
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 a pull request may close this issue.

2 participants