Skip to content

Server side LSP request hangs if executed from a notification handler #775

@MiklosMagyari

Description

@MiklosMagyari

I don't know if it is by design, but at least it was not trivial for me and took several hours to track down.

We have a language server built on lsp4j. Among many others, we implemented the handler for didChangeWorkspaceFolders. After handling the folder changes, we call the function performing a project build that creates a work progress:

@Override
public void didChangeWorkspaceFolders(DidChangeWorkspaceFoldersParams params) {
    ...
    build();  // at a point it sends work done progress create
    ...
}

It turned out that calling the build like this causes sending window/workDoneProgress/create request to hang. Checking the trace in vscode showed that the request has been sent out and vscode responded almost immediatelly, but the CompletableFuture returned by createProgress() did not complete.

Finally, I have changed the code to:

@Override
public void didChangeWorkspaceFolders(DidChangeWorkspaceFoldersParams params) {
    ...
    CompletableFuture.runAsync(() -> {
        build();
    });
    ...
}

This way I have no lockup.

Is it intentional that I practically need to exit notification handlers before sending out an LSP request?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions