vscode-reasonml icon indicating copy to clipboard operation
vscode-reasonml copied to clipboard

"Error: Connection got disposed" on save

Open nhjk opened this issue 7 years ago • 7 comments

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.

nhjk avatar Aug 25 '18 20:08 nhjk

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.

Nicd avatar Sep 05 '18 17:09 Nicd

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.

Huxpro avatar Sep 08 '18 04:09 Huxpro

@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."?

Huxpro avatar Sep 08 '18 04:09 Huxpro

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

slice avatar Sep 17 '18 04:09 slice

@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?

varunpatro avatar Feb 14 '19 11:02 varunpatro

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

mmathys avatar Sep 22 '19 13:09 mmathys

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

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

myegorov avatar Mar 08 '20 09:03 myegorov