LanguageServer.jl icon indicating copy to clipboard operation
LanguageServer.jl copied to clipboard

Long Standing Issue Replication

Open AlexvZyl opened this issue 2 years ago • 14 comments

I just got greeted with this message. As you can see, this is in Neovim.

image

I just want to check if this is relevant? If so, I am more than willing to provide any necessary information.

AlexvZyl avatar Oct 03 '22 13:10 AlexvZyl

Which version of LanguageServer.jl are you running? In particular, do you have https://github.com/julia-vscode/LanguageServer.jl/pull/1118 ?

Do you have any save-hooks (e.g. stripping trailing whitespace, formatting) installed?

fredrikekre avatar Oct 06 '22 09:10 fredrikekre

I just received this message again, but this time in a completely different scenario.

Version:

[2b0e0bc5] LanguageServer v4.3.1

LspInfo:

image

Save-Hooks:

I did not install any manually, but that does not mean that they are not present, I have quite a few plugins installed. If this is important to know I can try and dig through my plugins.

AlexvZyl avatar Oct 07 '22 11:10 AlexvZyl

completely different scenario.

What scenario? Also, I just noted the message in the top right corner in the first screenshot. Does that mean you renamed the file or something? Potentially related to https://github.com/neovim/neovim/issues/20129 in that case

fredrikekre avatar Oct 07 '22 11:10 fredrikekre

Scenario 1 (original screenshot):

Renamed a file.

Scenario 2:

I was scrolling through auto-completion results, as seen here. Though, I think by the time I was scrolling it already had all of the results, so I do not think it had something to do with the specific request.

image

AlexvZyl avatar Oct 07 '22 12:10 AlexvZyl

The error happens because there is a mismatch between what neovim things is the file content and what LanguageServer think is the file content.

Your first scenario might just be the neovim issue I linked then. For the second, I have also seen errors in the past with autocomplete, but not any more. I don't know exactly why it stopped though. Perhaps you can try using LanguageServer master branch and see if it still happens there.

fredrikekre avatar Oct 07 '22 12:10 fredrikekre

I will keep using my current version and post updates if I find any. Maybe I can gain some insight.

AlexvZyl avatar Oct 07 '22 12:10 AlexvZyl

Okay, so it was not the auto complete. It happens when I save a file, there is just a delay before the error message gets displayed and it made it look like it happened during the auto completion.

Interestingly, I am getting this issue very consistently now.

AlexvZyl avatar Oct 07 '22 12:10 AlexvZyl

Can you run with the branch fe/debug? Add it with the package manager: import Pkg; Pkg.add(name = "LanguageServer", rev = "fe/debug") That one should dump some more debug output: https://github.com/julia-vscode/LanguageServer.jl/commit/a5121d2550d7241dc306adc08d2f0c9d61b31f5e to your logfile (:lua print(vim.lsp.get_log_path())) which might give you a clue what the difference is.

fredrikekre avatar Oct 07 '22 12:10 fredrikekre

Sorry for only replying now. This is what my log file displays on a crash.

[ERROR][2022-10-13 14:15:41] .../vim/lsp/rpc.lua:733	"rpc"	"julia"	"stderr"	'┌ Warning: Mismatch between client and server\n│   get_text(doc) = "include(\\"Utilities.jl\\")\\n\\n# Packages used in the example.\\nusing Flux\\nusing Flux.Data: DataLoader\\nusing Flux.Optimise: Optimiser, WeightDecay\\nusing Flux: onehotbatch, onecold, flatten\\nusing Flux.Losses: logitcrossentropy\\nusing Statistics, Random\\nusing Log" ⋯ 2183 bytes ⋯ " = args.use_cuda && CUDA.functional()\\n\\n    # Display training device.\\n    if use_cuda\\n        device = gpu\\n        @info \\"Training on GPU.\\"\\n    else\\n        device = cpu\\n        @info \\"Training on CPU.\\"\\n    end\\n\\nend\\n\\n# Run the training script.\\ntrain()\\n"\n│   params.text = "include(\\"Utilities.jl\\")\\n\\n# Packages used in the example.\\nusing Flux\\nusing Flux.Data: DataLoader\\nusing Flux.Optimise: Optimiser, WeightDecay\\nusing Flux: onehotbatch, onecold, flatten\\nusing Flux.Losses: logitcrossentropy\\nusing Statistics, Random\\nusing Log" ⋯ 2182 bytes ⋯ "a = args.use_cuda && CUDA.functional()\\n\\n    # Display training device\\n    if use_cuda\\n        device = gpu\\n        @info \\"Training on GPU.\\"\\n    else\\n        device = cpu\\n        @info \\"Training on CPU.\\"\\n    end\\n\\nend\\n\\n# Run the training script.\\ntrain()\\n"\n└ @ LanguageServer ~/.julia/packages/LanguageServer/91tfM/src/requests/textdocument.jl:49\n'
[ERROR][2022-10-13 14:15:41] .../vim/lsp/rpc.lua:733	"rpc"	"julia"	"stderr"	"ERROR: "
[ERROR][2022-10-13 14:15:42] .../vim/lsp/rpc.lua:733	"rpc"	"julia"	"stderr"	"Mismatch between server and client text for file:///home/alex/GitHub/Radar/Classification/CNN.jl. _open_in_editor is true. _workspace_file is true. _version is 0.\nStacktrace:\n"
[ERROR][2022-10-13 14:15:42] .../vim/lsp/rpc.lua:733	"rpc"	"julia"	"stderr"	" [1] textDocument_didSave_notification(params::"
[ERROR][2022-10-13 14:15:42] .../vim/lsp/rpc.lua:733	"rpc"	"julia"	"stderr"	"LanguageServer.DidSaveTextDocumentParams, server::LanguageServerInstance, conn::JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint})\n   @ LanguageServer "
[ERROR][2022-10-13 14:15:42] .../vim/lsp/rpc.lua:733	"rpc"	"julia"	"stderr"	"~/.julia/packages/LanguageServer/91tfM/src/requests/textdocument.jl:51\n [2] "
[ERROR][2022-10-13 14:15:42] .../vim/lsp/rpc.lua:733	"rpc"	"julia"	"stderr"	'(::LanguageServer.var"#109#110"{typeof(LanguageServer.textDocument_didSave_notification), LanguageServerInstance})(conn::JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, params::LanguageServer.DidSaveTextDocumentParams)\n   @ LanguageServer ~/.julia/packages/LanguageServer/91tfM/src/languageserverinstance.jl:267\n'
[ERROR][2022-10-13 14:15:42] .../vim/lsp/rpc.lua:733	"rpc"	"julia"	"stderr"	" [3] dispatch_msg(x::"
[ERROR][2022-10-13 14:15:42] .../vim/lsp/rpc.lua:733	"rpc"	"julia"	"stderr"	"JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, dispatcher::JSONRPC.MsgDispatcher, msg::"
[ERROR][2022-10-13 14:15:42] .../vim/lsp/rpc.lua:733	"rpc"	"julia"	"stderr"	"Dict{String, Any})\n   @ JSONRPC ~/.julia/packages/JSONRPC/P0G1p/src/typed.jl:67\n [4] "
[ERROR][2022-10-13 14:15:42] .../vim/lsp/rpc.lua:733	"rpc"	"julia"	"stderr"	"run(server::LanguageServerInstance)\n   @ LanguageServer ~/.julia/packages/LanguageServer/91tfM/src/languageserverinstance.jl:387\n"
[ERROR][2022-10-13 14:15:42] .../vim/lsp/rpc.lua:733	"rpc"	"julia"	"stderr"	" [5] top-level scope\n   @ none:31\n"

AlexvZyl avatar Oct 13 '22 12:10 AlexvZyl

⋯ 2183 bytes ⋯

vs

⋯ 2182 bytes ⋯

:D

Looks like the mismatching byte is in between there at least. Let me see if we can make a patch that don't truncate the output.

fredrikekre avatar Oct 13 '22 13:10 fredrikekre

I just ran into this issue as well, also in nvim. I'm not working on an open source project so I don't feel comfortable sharing the full log, but I can share the diff between the client and server text as reported in the issue.

I don't recall what the last action I had taken was prior to the warning, but I know I had recently done an LSP rename op between costs and gen_costs. Some extra context is that I was inside of a @testset begin ... end block, not inside of a module.

LHS is client text, RHS is server text

50,52c50,51
<         gen_costs = gen_solution["costs"]
<         ecs = gen_costs["energyCredits"]
<         costs = solution["costs"]
---
>         costs = gen_solution["costs"]
>         ecs = costs["energyCredits"]
54c53
<         @test "energyCredits" in keys(gen_costs)
---
>         @test "energyCredits" in keys(costs)

The rest of the log info:

[ERROR][2023-06-14 14:02:18] .../vim/lsp/rpc.lua:734	"rpc"	"/home/sbuercklin/.julia/juliaup/bin/julia"	"stderr"	"ERROR: "
[ERROR][2023-06-14 14:02:18] .../vim/lsp/rpc.lua:734	"rpc"	"/home/sbuercklin/.julia/juliaup/bin/julia"	"stderr"	"Mismatch between server and client text for file:///home/sbuercklin/work/path/to/package/test/runtests.jl. _open_in_editor is true. _workspace_file is true. _version is 0."
[ERROR][2023-06-14 14:02:18] .../vim/lsp/rpc.lua:734	"rpc"	"/home/sbuercklin/.julia/juliaup/bin/julia"	"stderr"	"
Stacktrace:
 [1] textDocument_didSave_notification(params::"
[ERROR][2023-06-14 14:02:18] .../vim/lsp/rpc.lua:734	"rpc"	"/home/sbuercklin/.julia/juliaup/bin/julia"	"stderr"	"LanguageServer.DidSaveTextDocumentParams, server::"
[ERROR][2023-06-14 14:02:18] .../vim/lsp/rpc.lua:734	"rpc"	"/home/sbuercklin/.julia/juliaup/bin/julia"	"stderr"	"LanguageServerInstance, conn::JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint})
   @ LanguageServer ~/.julia/packages/LanguageServer/ad2Yz/src/requests/textdocument.jl:57"
[ERROR][2023-06-14 14:02:18] .../vim/lsp/rpc.lua:734	"rpc"	"/home/sbuercklin/.julia/juliaup/bin/julia"	"stderr"	"
 [2]"
[ERROR][2023-06-14 14:02:18] .../vim/lsp/rpc.lua:734	"rpc"	"/home/sbuercklin/.julia/juliaup/bin/julia"	"stderr"	" "
[ERROR][2023-06-14 14:02:18] .../vim/lsp/rpc.lua:734	"rpc"	"/home/sbuercklin/.julia/juliaup/bin/julia"	"stderr"	'(::LanguageServer.var"#111#112"{typeof(LanguageServer.textDocument_didSave_notification), LanguageServerInstance})(conn::'
[ERROR][2023-06-14 14:02:18] .../vim/lsp/rpc.lua:734	"rpc"	"/home/sbuercklin/.julia/juliaup/bin/julia"	"stderr"	"JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, params::LanguageServer.DidSaveTextDocumentParams)
   @ LanguageServer ~/.julia/packages/LanguageServer/ad2Yz/src/languageserverinstance.jl:267
"
[ERROR][2023-06-14 14:02:18] .../vim/lsp/rpc.lua:734	"rpc"	"/home/sbuercklin/.julia/juliaup/bin/julia"	"stderr"	" [3] dispatch_msg(x"
[ERROR][2023-06-14 14:02:18] .../vim/lsp/rpc.lua:734	"rpc"	"/home/sbuercklin/.julia/juliaup/bin/julia"	"stderr"	"::JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, dispatcher::"
[ERROR][2023-06-14 14:02:18] .../vim/lsp/rpc.lua:734	"rpc"	"/home/sbuercklin/.julia/juliaup/bin/julia"	"stderr"	"JSONRPC.MsgDispatcher, msg::"
[ERROR][2023-06-14 14:02:18] .../vim/lsp/rpc.lua:734	"rpc"	"/home/sbuercklin/.julia/juliaup/bin/julia"	"stderr"	"Dict{String, Any})
   @ JSONRPC "
[ERROR][2023-06-14 14:02:18] .../vim/lsp/rpc.lua:734	"rpc"	"/home/sbuercklin/.julia/juliaup/bin/julia"	"stderr"	"~/.julia/packages/JSONRPC/Q0FBr/src/typed.jl:67
 [4] "
[ERROR][2023-06-14 14:02:18] .../vim/lsp/rpc.lua:734	"rpc"	"/home/sbuercklin/.julia/juliaup/bin/julia"	"stderr"	"run(server::"
[ERROR][2023-06-14 14:02:18] .../vim/lsp/rpc.lua:734	"rpc"	"/home/sbuercklin/.julia/juliaup/bin/julia"	"stderr"	"LanguageServerInstance)
   @ LanguageServer ~/.julia/packages/LanguageServer/ad2Yz/src/languageserverinstance.jl:387
 "
[ERROR][2023-06-14 14:02:18] .../vim/lsp/rpc.lua:734	"rpc"	"/home/sbuercklin/.julia/juliaup/bin/julia"	"stderr"	"[5] top-level scope
   @ none:31
"

SBuercklin avatar Jun 14 '23 18:06 SBuercklin

Yeah, I also regularly still get this issue. If you want more logs or help debugging @fredrikekre, just give a shout.

AlexvZyl avatar Jun 15 '23 14:06 AlexvZyl

I never see this myself, except for https://github.com/neovim/neovim/issues/20129, with empty files, so my best bet is some plugin you are using that I don't. Perhaps you can comment out plugins until this don't happen or something.

fredrikekre avatar Jun 15 '23 15:06 fredrikekre

I just found a minimal-ish reproduction using a snippet and autoformatting in nvim. I have the following snippet I use with luasnip, and the .JuliaFormatter.toml is just blue style:

snippet function_nodoc Function without docstring
	function $1($2)
		$3
		return nothing
	end

In an empty buffer, I use that snippet and end up at $3 where my cursor is marked by |:

function a(b)
    |
    return nothing
end

Instead of entering anything, I go to command mode and save. Then, the autoformatter will delete the line my cursor is on and I end up with

function a(b)
    return nothing
end

and I get the error notification

SBuercklin avatar Aug 24 '23 16:08 SBuercklin