Skip to content

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

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

Closed
jhrcek opened this issue Jun 9, 2021 · 7 comments
Closed
Labels
component: lsp type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. type: enhancement New feature or request

Comments

@jhrcek
Copy link
Collaborator

jhrcek commented Jun 9, 2021

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.

@jneira
Copy link
Member

jneira commented Jun 9, 2021

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 jneira added type: documentation type: enhancement New feature or request type: support User support tickets, questions, help with setup etc. labels Jun 9, 2021
@jhrcek
Copy link
Collaborator Author

jhrcek commented Jun 10, 2021

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 🙏

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

@jneira
Copy link
Member

jneira commented Jun 10, 2021

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

@michaelpj
Copy link
Collaborator

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
Copy link
Collaborator

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

@fendor fendor added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. and removed old_type: documentation labels Jul 13, 2022
@michaelpj michaelpj removed the type: support User support tickets, questions, help with setup etc. label Mar 22, 2023
@michaelpj
Copy link
Collaborator

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

@jhrcek
Copy link
Collaborator Author

jhrcek commented Jan 31, 2024

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

@jhrcek jhrcek closed this as completed Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: lsp type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants