haskell-language-server icon indicating copy to clipboard operation
haskell-language-server copied to clipboard

"Trace server messages" setting doesn't show LSP JSON-RPC messages in the logs

Open jhrcek opened this issue 4 years ago • 5 comments

Your environment

Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools:

haskell-language-server version: 1.1.0.1 (GHC: 8.8.4) (PATH: /home/jhrcek/.local/bin/haskell-language-server) (GIT hash: 0cc89d209791c4bc200bf582f0e5f2a8b2465220)
Tool versions found on the $PATH
cabal:		3.4.0.0
stack:		2.7.1
ghc:		8.8.4

Which OS do you use:

  • Fedora 34

Which lsp-client do you use:

  • vscode

Steps to reproduce

In vscode haskell extension setting set "Haskell > Trace: server" to "messages" (and then restart vscode to be sure extension setting was applied)

Expected behaviour

When I go to View > Output and select "Haskell" I'm expecting to see JSON-RPC messages being exchanged between vscode-haskell extension and haskell-language-server. I'm pretty sure I saw messages like these when I used to use hie (haskell-ide-engine) but in HLS this setting doesn't seem to have any effect.

Actual behaviour

I "only" see debug messages, but no JSON-RPC messages.

jhrcek avatar Jun 09 '21 09:06 jhrcek

Hi, thanks for asking the question. To enable messages you can set the env var LSP_TEST_LOG_MESSAGES=true (see an example in the github test workflow, where other related env vars are used) I guess the amount of log with messages enabled is overwhelming so it is better to not show them by default. Maybe another mechanism could be used though (TRACE log level? an option to pass to hls executable?) Definitely it should be documented somewhere and be easily discoverable.

EDIT: The use of the en var is documented in the lsp package: https://github.com/haskell/lsp/blob/master/README.md but i think it is worth to add them here, in the troubleshooting section: https://github.com/haskell/haskell-language-server#troubleshooting-the-server prs welcome, as usual 😃

jneira avatar Jun 09 '21 15:06 jneira

Thanks for the details. I'll gladly document this once I managed to turn on the message tracing. So far I tried couple of ways, e.g. I added these to my .bashrc

export LSP_TEST_LOG_MESSAGES=true
export LSP_TEST_LOG_STDERR=true

after sourcing it I started vscode and double checked that those env vars are indeed set for the haskell-language-server process:

$ strings /proc/$(pidof haskell-language-server-8.8.4)/environ | grep LSP --color
LSP_TEST_LOG_STDERR=true
LSP_TEST_LOG_MESSAGES=true

But I still couldn't see any json-rpc messages logged. I'll dig deeper into source code later and hopefully find a way to enable the message tracing, but in the meantime It would be helpful if you could check if you can enable those messages on your side :pray:

Is it possible that HLS is starting session in some way that ignores those env vars?

jhrcek avatar Jun 10 '21 11:06 jhrcek

Mmm maybe i overlooked it and only are taken in account when the session is started using lsp-test (ultimately the env var names have TEST) In that case we should port or move the behaviour to lsp itself (or in hls if lsp itself is not suitable)

EDIT: I think that is the case, sorry for the confusion:

https://github.com/haskell/lsp/blob/907a69791cca89391b3831b6a113882b9d99463a/lsp-test/src/Language/LSP/Test.hs#L264-L272

jneira avatar Jun 10 '21 11:06 jneira

Seconded, this was very useful and it would be good to have it back! (Fortunately you can still get this from the client with the Emacs client)

michaelpj avatar Sep 09 '21 12:09 michaelpj

I think this ultimately means that -d no longer emits these.

michaelpj avatar Sep 09 '21 12:09 michaelpj

Not sure if this is outdated but I think it's still somewhat useful to get the messages.

michaelpj avatar Mar 22 '23 12:03 michaelpj

This is no longer an issue. Setting "Haskell > Trace: Server" to "verbose" in vscode shows the client-server messages in the output window.

jhrcek avatar Jan 31 '24 16:01 jhrcek