haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.65k stars 355 forks source link

HLS simply stops working #3923

Closed mitchellwrosen closed 4 months ago

mitchellwrosen commented 8 months ago

Hello all, apologies for the low-quality bug report, but I wasn't able to find anything like this in the issue tracker.

Put simply, HLS simply tends to stop working, especially on bigger projects (but why does that matter?)

For example, I'm currently poking around the cabal codebase for the first time. You can follow along by:

I also have ghcid running in another terminal with ghcid -c 'cabal repl cabal-install', which seems to always report accurate information. That's the easiest way to tell when HLS is wrong - at some point it stops agreeing with ghcid, and it's always wrong when it does.

In a third terminal I have the LSP logs visible at TRACE level. I can see that (when HLS becomes broken) it still seems to be handling many requests. Here's an ugly dump:

``` [TRACE][2023-12-29 15:56:49] .../lua/vim/lsp.lua:1053 "notification" "$/progress" { token = "2005", value = { kind = "begin", title = "Processing" }} [TRACE][2023-12-29 15:56:49] ...lsp/handlers.lua:618 "default_handler" "$/progress" { ctx = '{\n client_id = 1,\n method = "$/progress"\n}', result = { token = "2005", value = { kind = "begin", title = "Processing" } }} [DEBUG][2023-12-29 15:56:49] .../vim/lsp/rpc.lua:387 "rpc.receive" { jsonrpc = "2.0", method = "$/progress", params = { token = "2005", value = { kind = "report", message = "596/599" } }} [TRACE][2023-12-29 15:56:49] .../lua/vim/lsp.lua:1053 "notification" "$/progress" { token = "2005", value = { kind = "report", message = "596/599" }} [TRACE][2023-12-29 15:56:49] ...lsp/handlers.lua:618 "default_handler" "$/progress" { ctx = '{\n client_id = 1,\n method = "$/progress"\n}', result = { token = "2005", value = { kind = "report", message = "596/599" } }} [DEBUG][2023-12-29 15:56:49] .../lua/vim/lsp.lua:1392 "LSP[haskell]" "client.request" 1 "textDocument/codeLens" { textDocument = { uri = "file:///home/mitchell/code/forks/cabal/cabal-install/src/Distribution/Client/Main.hs" }} 2 [DEBUG][2023-12-29 15:56:49] .../vim/lsp/rpc.lua:284 "rpc.send" { id = 419, jsonrpc = "2.0", method = "textDocument/codeLens", params = { textDocument = { uri = "file:///home/mitchell/code/forks/cabal/cabal-install/src/Distribution/Client/Main.hs" } }} [DEBUG][2023-12-29 15:56:49] .../vim/lsp/rpc.lua:387 "rpc.receive" { jsonrpc = "2.0", method = "$/progress", params = { token = "2005", value = { kind = "report", message = "325/599" } }} [TRACE][2023-12-29 15:56:49] .../lua/vim/lsp.lua:1053 "notification" "$/progress" { token = "2005", value = { kind = "report", message = "325/599" }} [TRACE][2023-12-29 15:56:49] ...lsp/handlers.lua:618 "default_handler" "$/progress" { ctx = '{\n client_id = 1,\n method = "$/progress"\n}', result = { token = "2005", value = { kind = "report", message = "325/599" } }} [DEBUG][2023-12-29 15:56:49] .../vim/lsp/rpc.lua:387 "rpc.receive" { jsonrpc = "2.0", method = "$/progress", params = { token = "2005", value = { kind = "report", message = "322/599" } }} [TRACE][2023-12-29 15:56:49] .../lua/vim/lsp.lua:1053 "notification" "$/progress" { token = "2005", value = { kind = "report", message = "322/599" }} [TRACE][2023-12-29 15:56:49] ...lsp/handlers.lua:618 "default_handler" "$/progress" { ctx = '{\n client_id = 1,\n method = "$/progress"\n}', result = { token = "2005", value = { kind = "report", message = "322/599" } }} [DEBUG][2023-12-29 15:56:49] .../vim/lsp/rpc.lua:387 "rpc.receive" { id = 419, jsonrpc = "2.0", result = {}} [DEBUG][2023-12-29 15:56:49] .../vim/lsp/rpc.lua:387 "rpc.receive" { jsonrpc = "2.0", method = "$/progress", params = { token = "2005", value = { kind = "end" } }} [TRACE][2023-12-29 15:56:49] .../lua/vim/lsp.lua:1053 "notification" "$/progress" { token = "2005", value = { kind = "end" }} [TRACE][2023-12-29 15:56:49] ...lsp/handlers.lua:618 "default_handler" "$/progress" { ctx = '{\n client_id = 1,\n method = "$/progress"\n}', result = { token = "2005", value = { kind = "end" } }} ```

But within the editor, I'm no longer getting any feedback whatsoever. I just have to restart HLS, and then it works again.

Again, apologies for the relatively low-quality bug report. I just wanted to make sure that this issue is known. I'd be happy to jump on a call to assist in collecting more information, if that would be helpful. It's easy for me to trigger this behavior on my end. Thanks!

fendor commented 8 months ago

I noticed this for the cabal codebase as well. I think it is a symptom of lacking multiple home unit support which requires cabal 3.12 and HLS head to work properly.

michaelpj commented 4 months ago

Is this reproducible with the latest HLS and cabal?

mitchellwrosen commented 4 months ago

Yes, it is, and I have a slightly more detailed repro this time around:

fendor commented 4 months ago

That's exactly the kind of issues that should be fixed by multi-repl: True, once cabal-3.12 is released.

Ill try to use it.

fendor commented 4 months ago

Works with the pre-release and HLS 2.8.0.0: image

Note the hover on the right.

michaelpj commented 4 months ago

Okay, tentatively closing, then.