ocaml-lsp icon indicating copy to clipboard operation
ocaml-lsp copied to clipboard

LSP errors are very noisy

Open dyedgreen opened this issue 2 years ago • 7 comments

The LSP/ merlin seems to raise in a lot of cases (leading to the LSP query to return an error), where I would expect it to just return an empty result.

For example, asking to go to definition on let raises an error “Not in environment: let”. (Rather than returning an empty result indicating that there are no definitions available.)

This is particularly annoying when using the LSP in VSCode since the errors lead to an error notification every time and the editor queries eg for go to definition whenever you press ctrl.

dyedgreen avatar Jul 06 '23 12:07 dyedgreen

I can reproduce the issue with let. I agree that we shouldn't be producing an error in these cases.

Are you seeing this issue in other contexts?

jfeser avatar Jul 06 '23 15:07 jfeser

This also seems to happen very frequently inside of various PPXs.

dyedgreen avatar Jul 06 '23 15:07 dyedgreen

A few thoughts:

  • Right now, merlin returns Not_in_env for syntax like let, match, begin, etc. It should return Invalid_context instead, which we handle appropriately. This is a merlin bug.
  • We should log locate errors instead of returning an error response to the user.

jfeser avatar Jul 06 '23 15:07 jfeser

The signature help RPC also seems to have similar, but less frequently occurring issue.

dyedgreen avatar Jul 08 '23 01:07 dyedgreen

Can you give an example of the issue with signature help?

jfeser avatar Jul 11 '23 12:07 jfeser

I think it’s a similar issue to go-to-definition, but it seems to happen less frequently; so addressing the go-to-definition noise is much higher value.

dyedgreen avatar Jul 15 '23 16:07 dyedgreen

I encountered this issue very offen. VScode console output:

[Info - 10:46:31] Ocamlformat-RPC server started with PID 18986 [Error - 10:51:55] Request textDocument/definition failed. Message: Request "Jump to definition" failed. Code: -32803 'Locate' query to merlin returned error: not in environment: each [Error - 10:51:55] Request textDocument/definition failed. Message: Request "Jump to definition" failed. Code: -32803 'Locate' query to merlin returned error: not in environment: The [Error - 10:55:23] Request textDocument/definition failed. Message: Request "Jump to definition" failed. Code: -32803 'Locate' query to merlin returned error: not in environment: Load [Error - 10:55:23] Request textDocument/definition failed. Message: Request "Jump to definition" failed. Code: -32803 'Locate' query to merlin returned error: not in environment: determine [Error - 10:58:15] Server process exited with signal SIGBUS. [Info - 10:58:15] Connection to server got closed. Server will restart. true [Error - 10:58:15] Server process exited with signal SIGBUS. [Info - 10:58:15] Connection to server got closed. Server will restart. true

anthonygao avatar Dec 13 '23 03:12 anthonygao