Skip to content
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

Lsp issue when using [@react.component] inside a module #853

Closed
benbellick opened this issue Aug 26, 2024 · 4 comments
Closed

Lsp issue when using [@react.component] inside a module #853

benbellick opened this issue Aug 26, 2024 · 4 comments

Comments

@benbellick
Copy link

benbellick commented Aug 26, 2024

The Ocaml lsp seems to be broken when used with reason-react. For example, turning on the LSP and using eglot from within emacs, and then navigating to the first line of the below sample yields the error pasted below:

module Broken = {
  [@react.component]
    let make =
    (
      ~message: string
    ) => <p> {React.string(message)} </p>;
};

⛔ Warning (jsonrpc): Invalid JSON: (unable to decode byte 0xc0 1 193 193) {"params":{"message":"An error occured while querying ocamlformat:\nInput type: {\n external makeProps:\n (~message: string, ~key: string=?, unit) => {.. "message": string} = ""\n "����\u0000\u0000\u0000\u001b\u0000\u0000\u0000\u000b\u0000\u0000\u0000\u001e\u0000\u0000\u0000\u001d���A�'message��A�#key@��@@@";\n let make: {.. "message": string} => React.element;\n}\n\nAnswer: ocamlformat-rpc: ignoring "" (syntax error)\nFile "", line 1, characters 5-6:\nError: Syntax error\nocamlformat-rpc: ignoring "" (syntax error)\nFile "", line 1, characters 0-5:\nError: Syntax error\nocamlformat-rpc: ignoring "" (syntax error)\nFile "", line 1, characters 5-6:\nError: Syntax error\nocamlformat-rpc: ignoring "" (syntax error)\nFile "", line 1, characters 0-1:\nError: Syntax error\nocamlformat-rpc: ignoring "" (syntax error)\nFile "", line 1, characters 0-1:\nError: Syntax error\nocamlformat-rpc: ignoring "" (syntax error)\nFile "", line 1, characters 0-1:\nError: Syntax error\nocamlformat-rpc: ignoring "" (syntax error)\nFile "", line 2, characters 2-10:\nError: Syntax error\nocamlformat-rpc: ignoring "" (syntax error)\nFile "", line 2, characters 2-10:\nError: Syntax error\n","type":2},"method":"window/logMessage","js

Not sure if the problem is here or somewhere upstream, but wanted to get it down somewhere. Thanks!

versions:
ocaml-lsp-server: 1.17.0
reason-react: 0.14.0
reason-react-ppx: 0.14.0
dune: 3.15.2
melange: 3.0.0-51

@davesnx
Copy link
Member

davesnx commented Aug 26, 2024

Can you specify the dune and melange versions?

@benbellick
Copy link
Author

Edited to include them!

@jchavarri
Copy link
Collaborator

It would be helpful if this could be tested with most recent versions of dependencies (using opam update && opam upgrade, might need to upgrade the ocaml compiler manually):

ocaml 5.2
melange 4.0.1-52
reason-react 0.15.0
ocaml-lsp-server 0.19.0

There were some issues with the editor integration that were solved in these versions.

Even with the latest versions, the problem might still happen if it's caused by the externals containing binary information, see related melange-re/melange#749.

@benbellick
Copy link
Author

Thanks for the responses.
With the exact versions, the error still persists.

[jsonrpc] (warning) Invalid JSON: (unable to decode byte 0xc0 <callback> 1 156 156) 
...

I believe that that related issue though may be the core of the issue. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@jchavarri @davesnx @benbellick and others