Skip to content

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

Closed

Description

@ChristophKaser

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 https://github.com/eclipse/lsp4e/blob/9cdd9be00121f8c7fc386763e886d4e6a5f98787/org.eclipse.lsp4e/src/org/eclipse/lsp4e/LanguageServerWrapper.java#L256.

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

Activity

  1. mickaelistria commented on Sep 13, 2023

    @mickaelistria
    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!

  2. added a commit that references this issue on Sep 14, 2023
    503ad2b
  3. ChristophKaser commented on Sep 14, 2023

    @ChristophKaser
    ContributorAuthor

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

  4. added a commit that references this issue on Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions