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

Crash with invalid JSON #517

Open
NobbZ opened this issue Jun 12, 2024 · 5 comments
Open

Crash with invalid JSON #517

NobbZ opened this issue Jun 12, 2024 · 5 comments

Comments

@NobbZ
Copy link

NobbZ commented Jun 12, 2024

After some while of working (usually about 30 to 60 minutes) next-ls crashes and can not recover.

After some digging I found the following logs in .elixir-tools/next-ls.log, but not in the "Next LS" output pane of VS Code, I am therefore unsure whether this is a problem of the VScode plugin or NextLS.

14:36:33.638 [error] GenServer NextLS.Buffer terminating
** (Jason.DecodeError) unexpected end of input at position 286
    (jason 1.4.1) lib/jason.ex:92: Jason.decode!/2
    (gen_lsp 0.10.0) lib/gen_lsp/buffer.ex:87: anonymous fn/3 in GenLSP.Buffer.handle_cast/2
    (telemetry 1.2.1) /Users/runner/work/next-ls/next-ls/deps/telemetry/src/telemetry.erl:321: :telemetry.span/3
    (gen_lsp 0.10.0) lib/gen_lsp/buffer.ex:85: GenLSP.Buffer.handle_cast/2
    (stdlib 5.2) gen_server.erl:1121: :gen_server.try_handle_cast/3
    (stdlib 5.2) gen_server.erl:1183: :gen_server.handle_msg/6
    (stdlib 5.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
Last message: {:"$gen_cast", {:incoming, "\n{\"jsonrpc\":\"2.0\",\"id\":1112,\"method\":\"textDocument/completion\",\"params\":{\"textDocument\":{\"uri\":\"file:///home/nmelzer/Projects/BravoBike/**redacted****/apps/frontend/lib/frontend/live/**redacted****/overview.ex\"},\"position\":{\"line\":141,\"character\":21},\"context\":{\"triggerKind\":1}}"}}
State: %{lsp: #PID<0.256.0>, awaiting_response: %{}, comm_data: nil, comm: GenLSP.Communication.Stdio}

In fact the JSON snippet seen in the last message looks like this after clean up:

{
    "jsonrpc":"2.0",
    "id":1112,
    "method":"textDocument/completion",
    "params":{
        "textDocument":{
            "uri":""file:///home/nmelzer/Projects/BravoBike/**redacted****/apps/frontend/lib/frontend/live/**redacted****/overview.ex"
        },
        "position":{
            "line":141,
            "character":21
        },
        "context":{
            "triggerKind":1
        }
    }

So there is a closing curly brace missing.

@mhanberg
Copy link
Collaborator

This is a GenLSP (the framework that Next LS uses for LSP protocol stuff) issue, not the vscode extension issue

I have seen this a couple of times, but haven't been able to reproduce. Its unclear to me if under the hood we are not executing the protocol correctly, or if the editor is sending the wrong Content-Length header.

@mhanberg mhanberg transferred this issue from elixir-tools/elixir-tools.vscode Jun 12, 2024
@mhanberg
Copy link
Collaborator

The fact that it starts with a new line implies to me that an extra new line was sent or a new line was not properly consumed on the last message, so then it offset the payload by a character

@NobbZ
Copy link
Author

NobbZ commented Jun 12, 2024

Can I somehow increase log verbosity to perhaps see massages as they get created and consumed?

@mhanberg
Copy link
Collaborator

In the VScode extension you can set one of the next LS options to trace and it'll print out a lot more stuff.

@mhanberg
Copy link
Collaborator

CleanShot 2024-06-12 at 10 43 02@2x

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

No branches or pull requests

2 participants