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

In neovim, setting fileformat crashes julials

Open meriops opened this issue 3 years ago • 6 comments

In neovim, if I manually set the fileformat with :set fileformat=unix and then save the (julia) buffer with :w while the languageserver is running (ie "attached to the buffer"), the languageserver process crashes. It is not particularly bothering, because I rarely need to change the fileformat, but I get the message "Please contact us! Your extension just crashed with a bug that we have been trying to replicate for a long time", so I figured I'd drop a line here ...

meriops avatar Feb 21 '22 16:02 meriops

Can you get some more output (e.g. the LS stacktrace)?

pfitzseb avatar Feb 21 '22 16:02 pfitzseb

Here is the lsp.log file; I think it contains the LS stacktrace. If not please let me know how to get the LS stacktrace specifically.

meriops avatar Feb 21 '22 16:02 meriops

So I have noticed similar issues, it seems like the server crashes when the file is completely changed (for example if I do ggdG in neovim, or I run Julia formatter on the entire file, it will crash)

josephsdavid avatar Sep 09 '22 03:09 josephsdavid

I can reproduce that.

fredrikekre avatar Sep 09 '22 06:09 fredrikekre

neovim trace log:

[DEBUG][2022-09-09 08:37:08] .../vim/lsp/rpc.lua:347	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didChange",  params = {    contentChanges = { {        range = {          end = {            character = 0,            line = 9          },          start = {            character = 0,            line = 0          }        },        rangeLength = 96,        text = ""      } },    textDocument = {      uri = "file:///home/fredrik/dev/TestPackage/src/TestPackage.jl",      version = 4    }  }}
[DEBUG][2022-09-09 08:37:09] .../vim/lsp/rpc.lua:454	"rpc.receive"	{  jsonrpc = "2.0",  method = "textDocument/publishDiagnostics",  params = {    diagnostics = {},    uri = "file:///home/fredrik/dev/TestPackage/src/TestPackage.jl",    version = 4  }}
[TRACE][2022-09-09 08:37:09] .../lua/vim/lsp.lua:792	"notification"	"textDocument/publishDiagnostics"	{  diagnostics = {},  uri = "file:///home/fredrik/dev/TestPackage/src/TestPackage.jl",  version = 4}
[TRACE][2022-09-09 08:37:09] ...lsp/handlers.lua:488	"default_handler"	"textDocument/publishDiagnostics"	{  ctx = '{\n  client_id = 1,\n  method = "textDocument/publishDiagnostics"\n}',  result = {    diagnostics = {},    uri = "file:///home/fredrik/dev/TestPackage/src/TestPackage.jl",    version = 4  }}
[DEBUG][2022-09-09 08:37:26] .../vim/lsp/rpc.lua:347	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didSave",  params = {    text = "\n",    textDocument = {      uri = "file:///home/fredrik/dev/TestPackage/src/TestPackage.jl"    }  }}
[ERROR][2022-09-09 08:37:27] .../vim/lsp/rpc.lua:420	"rpc"	"julia"	"stderr"	"ERROR: "
[ERROR][2022-09-09 08:37:28] .../vim/lsp/rpc.lua:420	"rpc"	"julia"	"stderr"	"Mismatch between server and client text for file:///home/fredrik/dev/TestPackage/src/TestPackage.jl. _open_in_editor is true. _workspace_file is true. _version is 4."
[DEBUG][2022-09-09 08:37:28] .../vim/lsp/rpc.lua:454	"rpc.receive"	{  jsonrpc = "2.0",  method = "window/showMessage",  params = {    message = "Julia Extension: Please contact us! Your extension just crashed with a bug that we have been trying to replicate for a long time. You could help the development team a lot by contacting us at https://github.com/julia-vscode/julia-vscode so that we can work together to fix this issue.",    type = 1  }}
[TRACE][2022-09-09 08:37:28] .../lua/vim/lsp.lua:792	"notification"	"window/showMessage"	{  message = "Julia Extension: Please contact us! Your extension just crashed with a bug that we have been trying to replicate for a long time. You could help the development team a lot by contacting us at https://github.com/julia-vscode/julia-vscode so that we can work together to fix this issue.",  type = 1}
[TRACE][2022-09-09 08:37:28] ...lsp/handlers.lua:488	"default_handler"	"window/showMessage"	{  ctx = '{\n  client_id = 1,\n  method = "window/showMessage"\n}',  result = {    message = "Julia Extension: Please contact us! Your extension just crashed with a bug that we have been trying to replicate for a long time. You could help the development team a lot by contacting us at https://github.com/julia-vscode/julia-vscode so that we can work together to fix this issue.",    type = 1  }}
[ERROR][2022-09-09 08:37:28] .../vim/lsp/rpc.lua:420	"rpc"	"julia"	"stderr"	"\nStacktrace:\n [1] "
[ERROR][2022-09-09 08:37:28] .../vim/lsp/rpc.lua:420	"rpc"	"julia"	"stderr"	"textDocument_didSave_notification(params::"
[ERROR][2022-09-09 08:37:28] .../vim/lsp/rpc.lua:420	"rpc"	"julia"	"stderr"	"LanguageServer.DidSaveTextDocumentParams, server::LanguageServerInstance, conn::"
[ERROR][2022-09-09 08:37:28] .../vim/lsp/rpc.lua:420	"rpc"	"julia"	"stderr"	"JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint})\n   @ LanguageServer ~/dev/LanguageServer/src/requests/textdocument.jl:50\n [2] #invokelatest#2\n   @ ./essentials.jl:729 [inlined]\n [3] invokelatest\n   @ ./essentials.jl:726 [inlined]\n"
[ERROR][2022-09-09 08:37:28] .../vim/lsp/rpc.lua:420	"rpc"	"julia"	"stderr"	" [4] "
[ERROR][2022-09-09 08:37:28] .../vim/lsp/rpc.lua:420	"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 '
[ERROR][2022-09-09 08:37:28] .../vim/lsp/rpc.lua:420	"rpc"	"julia"	"stderr"	"~/dev/LanguageServer/src/languageserverinstance.jl:265\n [5] dispatch_msg(x::JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, dispatcher::JSONRPC.MsgDispatcher, msg::"
[ERROR][2022-09-09 08:37:28] .../vim/lsp/rpc.lua:420	"rpc"	"julia"	"stderr"	"Dict{String, Any})\n   @ JSONRPC ~/.julia/packages/JSONRPC/P0G1p/src/typed.jl:67\n "
[ERROR][2022-09-09 08:37:28] .../vim/lsp/rpc.lua:420	"rpc"	"julia"	"stderr"	"[6] run(server::LanguageServerInstance)"
[ERROR][2022-09-09 08:37:28] .../vim/lsp/rpc.lua:420	"rpc"	"julia"	"stderr"	"\n   @ LanguageServer ~/dev/LanguageServer/src/languageserverinstance.jl:387\n"
[ERROR][2022-09-09 08:37:28] .../vim/lsp/rpc.lua:420	"rpc"	"julia"	"stderr"	" [7] top-level scope\n   @ none:31\n"
[INFO][2022-09-09 08:37:32] .../lua/vim/lsp.lua:1392	"exit_handler"	{}

fredrikekre avatar Sep 09 '22 06:09 fredrikekre

I think this may be neovims fault:

┌ Info: Before applying
└   (get_text_document(doc))._content = "module TestPackage\\nend\\n"
┌ Info: After applying
└   new_text_document._content = ""
┌ Info: When saving
└   params.text = "\\n"

and probably because neovim appends a newline when saving, but never sending a LS notification about that. The error doesn't happen if you :set noeol.

fredrikekre avatar Sep 09 '22 07:09 fredrikekre