reasonml-editor / vscode-reasonml

OCaml & Reason support for Visual Studio Code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Error: Connection got disposed" on save

nhjk opened this issue · comments

commented

When I try to save a file I get the following error output:

[Error - 4:14:31 PM] Connection to server got closed. Server will not be restarted.
[Error - 4:14:31 PM] Request textDocument/formatting failed.
Error: Connection got disposed.
	at Object.dispose (/Users/[redacted]/.vscode/extensions/freebroccolo.reasonml-1.0.38/node_modules/vscode-jsonrpc/lib/main.js:825:25)
	at Object.dispose (/Users/[redacted]/.vscode/extensions/freebroccolo.reasonml-1.0.38/node_modules/vscode-languageclient/lib/client.js:57:35)
	at LanguageClient.handleConnectionClosed (/Users/[redacted]/.vscode/extensions/freebroccolo.reasonml-1.0.38/node_modules/vscode-languageclient/lib/client.js:1954:42)
	at LanguageClient.handleConnectionClosed (/Users/[redacted]/.vscode/extensions/freebroccolo.reasonml-1.0.38/node_modules/vscode-languageclient/lib/main.js:126:15)
	at closeHandler (/Users/[redacted]/.vscode/extensions/freebroccolo.reasonml-1.0.38/node_modules/vscode-languageclient/lib/client.js:1941:18)
	at CallbackList.invoke (/Users/[redacted]/.vscode/extensions/freebroccolo.reasonml-1.0.38/node_modules/vscode-jsonrpc/lib/events.js:71:39)
	at Emitter.fire (/Users/[redacted]/.vscode/extensions/freebroccolo.reasonml-1.0.38/node_modules/vscode-jsonrpc/lib/events.js:135:36)
	at closeHandler (/Users/[redacted]/.vscode/extensions/freebroccolo.reasonml-1.0.38/node_modules/vscode-jsonrpc/lib/main.js:221:26)
	at CallbackList.invoke (/Users/[redacted]/.vscode/extensions/freebroccolo.reasonml-1.0.38/node_modules/vscode-jsonrpc/lib/events.js:71:39)
	at Emitter.fire (/Users/[redacted]/.vscode/extensions/freebroccolo.reasonml-1.0.38/node_modules/vscode-jsonrpc/lib/events.js:135:36)
	at IPCMessageReader.AbstractMessageReader.fireClose (/Users/[redacted]/.vscode/extensions/freebroccolo.reasonml-1.0.38/node_modules/vscode-jsonrpc/lib/messageReader.js:135:27)
	at ChildProcess.<anonymous> (/Users/[redacted]/.vscode/extensions/freebroccolo.reasonml-1.0.38/node_modules/vscode-jsonrpc/lib/messageReader.js:253:61)
	at emitTwo (events.js:131:20)
	at ChildProcess.emit (events.js:214:7)
	at maybeClose (internal/child_process.js:925:16)
	at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)

The syntax highlighting works but I'm not sure if anything else does.

I've installed reason according to the instructions at https://reasonml.github.io/docs/en/installation.
This is just yarn global add bs-platform.

Also the link in the readme of this project (in section https://github.com/reasonml-editor/vscode-reasonml#reason) is outdated, I can send a pull request to update it if you want.

I also have this problem.

Workaround: The part crashing is the formatter. In your settings, use this to prevent autoformatting OCaml files:

  "[ocaml]": {
    "editor.formatOnSave": false
  },

You may need to add another block for ReasonML, if you are using that.

It's probably replicated with #142

Formatting on save for OCaml requires having ocp-indent installed (usually via opam). That may be why you are seeing this error.

@freebroccolo I actually encounter this issue today myself. 😆It works for me after I installed ocp-indent.
I can probably help tho. Would you mind pointing out where can we catch this exception and "provide some better feedback about this in upcoming versions."?

I'm still getting this error even with ocp-indent installed.

@freebroccolo Is there an update on this?

Here's a snippet of my errors:

[Error - 7:37:57 PM] Connection to server got closed. Server will not be restarted.
[Error - 7:37:57 PM] Request textDocument/formatting failed.
Error: Connection got disposed.
	at Object.dispose (/Users/varun/.vscode/extensions/freebroccolo.reasonml-1.0.38/node_modules/vscode-jsonrpc/lib/main.js:825:25)

In your ocaml-language-server repo, you say I need ocaml version 4.02.3. Do you think that is the cause?

I fixed this issue by installing ocp-indent with opam install ocp-indent.

Fixed by adding the path to ocp-indent to settings.json:

{
    ...
    "editor.formatOnSave": true,
    "reason.path.ocpindent": "/path/to/ocp-indent",
    ...
}