Theia: Crash of the LanguageServer in the Julia VS code extension

Created on 4 Sep 2020  路  7Comments  路  Source: eclipse-theia/theia

Bug Description:

The Julia VS Code extension installs correctly within Theia. However, when using it, the LanguageServer frequently crashes, due to requests looking like:

[Trace - 10:56:22 AM] Sending request 'julia/getModuleAt - (37)'.
Params: {
    "textDocument": {
        "uri": "file:///home/project/theia-jl/test.jl"
    },
    "version": 30,
    "position": {
        "_line": 11,
        "_character": 0
    }
}

instead of the expected

[Trace - 10:56:22 AM] Sending request 'julia/getModuleAt - (37)'.
Params: {
    "textDocument": {
        "uri": "file:///home/project/theia-jl/test.jl"
    },
    "version": 30,
    "position": {
        "line": 11,
        "character": 0
    }
}

Steps to Reproduce:

  1. Run Theia from the theia-full docker image
  2. install Julia inside the docker container

    • see comment below for a Dockerfile automating this step

  3. install the Julia VS code extension (from the open VSX registry)
  4. open any Julia file and start typing some code, hovering over keywords...

    • see comment below for an example Julia source file

  5. the LanguageServer should crash pretty quickly


Additional Information

  • Operating System: Ubuntu
  • Theia Version: Theia Multi-Language Example
    @theia/callhierarchy 1.5.0
    @theia/console 1.5.0
    @theia/core 1.5.0
    @theia/cpp-debug 1.0.0
    @theia/debug 1.5.0
    @theia/editor 1.5.0
    @theia/editor-preview 1.5.0
    @theia/file-search 1.5.0
    @theia/filesystem 1.5.0
    @theia/getting-started 1.5.0
    @theia/git 1.5.0
    @theia/keymaps 1.5.0
    @theia/markers 1.5.0
    @theia/messages 1.5.0
    @theia/metrics 1.5.0
    @theia/mini-browser 1.5.0
    @theia/monaco 1.5.0
    @theia/navigator 1.5.0
    @theia/outline-view 1.5.0
    @theia/output 1.5.0
    @theia/plugin-ext 1.5.0
    @theia/plugin-ext-vscode 1.5.0
    @theia/preferences 1.5.0
    @theia/preview 1.5.0
    @theia/process 1.5.0
    @theia/scm 1.5.0
    @theia/scm-extra 1.5.0
    @theia/search-in-workspace 1.5.0
    @theia/task 1.5.0
    @theia/terminal 1.5.0
    @theia/typehierarchy 1.5.0
    @theia/userstorage 1.5.0
    @theia/variable-resolver 1.5.0
    @theia/vsx-registry 1.5.0
    @theia/workspace 1.5.0
docker help wanted vscode

Most helpful comment

So the Julia extension defines an interface

export interface VersionedTextDocumentPositionParams {
    textDocument: vslc.TextDocumentIdentifier,
    version: number,
    position: vscode.Position
}

which is then used via

const params: VersionedTextDocumentPositionParams = {
    textDocument: vslc.TextDocumentIdentifier.create(document.uri.toString()),
    version: document.version,
    position: position # this is a vscode.Position
}
vslc_language_client.sendRequest<string>('julia/getModuleAt', params)

e.g. here.

Turns out that Theia serializes the vscocde.Position in that object as

{
    "_line": 1,
    "_character":2
}

instead of VSCode's

{
    "line": 1,
    "character": 2
}

which is what our server expects. You could argue that we should define the serialization ourselves, but that's not quite in the spirit of Theia trying to support VSCode extensions out-of-the-box.

All 7 comments

In case it would help reproduce the issue, here are the contents of a Dockerfile allowing to build an image in which Julia is installed alongside Theia:

FROM theiaide/theia-full

# Install julia
#    /usr/local/bin/julia -> /opt/julia/bin/julia
RUN  wget -q -O /tmp/julia.tar.gz \
     https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.1-linux-x86_64.tar.gz
RUN  cd /opt \
     && sudo tar xvzf /tmp/julia.tar.gz \
     && sudo mv julia-* julia
RUN  sudo ln -sf /opt/julia/bin/julia /usr/local/bin/
RUN  rm /tmp/julia.tar.gz

I build and use it locally like so:

$ docker build -t theia-jl .
$ docker run -it --init -p 3000:3000 -v "/tmp:/home/project:cached" theia-jl

In such a docker image, the Julia VS code extension should install without any problem, and find the julia binary without any need for specific settings.

And here is an example of Julia source file in case it would help reproducing the issue:

function greet(name="World")
    println("Hello $(name)!")
end

greet()
greet("John")

@ffevotte can you reproduce it outside of docker, and preferably on master building from this repository?

Yes, I've been able to reproduce this issue in a fresh system, building everything from the master branch

Yes, I've been able to reproduce this issue in a fresh system, building everything from the master branch

Thank you for following up and confirming it's reproducible without the docker setup.
I did notice that there are multiple crash related issues for the extension which may certainly be related.

I don't think these crash issues with the VScode extension are related. The reason why I filed this issue with Theia is because this particular error does not happen with VS code. It looks like this problem happens because some sets of Position parameters are incorrectly serialized.

My understanding is that the serialization of LSP requests is not directly performed by the extension, but rather gets delegated to a javascript library (languageclient), which is normally provided by VS code. Would it be possible that the version of this library, as shipped by Theia, is not the same as VS Code?

So the Julia extension defines an interface

export interface VersionedTextDocumentPositionParams {
    textDocument: vslc.TextDocumentIdentifier,
    version: number,
    position: vscode.Position
}

which is then used via

const params: VersionedTextDocumentPositionParams = {
    textDocument: vslc.TextDocumentIdentifier.create(document.uri.toString()),
    version: document.version,
    position: position # this is a vscode.Position
}
vslc_language_client.sendRequest<string>('julia/getModuleAt', params)

e.g. here.

Turns out that Theia serializes the vscocde.Position in that object as

{
    "_line": 1,
    "_character":2
}

instead of VSCode's

{
    "line": 1,
    "character": 2
}

which is what our server expects. You could argue that we should define the serialization ourselves, but that's not quite in the spirit of Theia trying to support VSCode extensions out-of-the-box.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kpge picture kpge  路  3Comments

dhananjayharel picture dhananjayharel  路  3Comments

vince-fugnitto picture vince-fugnitto  路  3Comments

tetchel picture tetchel  路  3Comments

vince-fugnitto picture vince-fugnitto  路  3Comments