reasonml-editor / vscode-reasonml

OCaml & Reason support for Visual Studio Code
Apache License 2.0
491 stars 62 forks source link

Error "connection got disposed off" (but not on save as in #247 and #142 but on start/load) #274

Closed MSoegtropIMC closed 5 years ago

MSoegtropIMC commented 5 years ago

I am having the same (or very similar errors) as mentioned in #142 and #247, but not just on save but when I load an OCaml file. That is for me the VSCode plugin doesn't work at all. Some notes on my environment:

The error message I get (within 1s after loading any OCaml file):

events.js:167
      throw er; // Unhandled 'error' event
      ^

Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
    at doWrite (_stream_writable.js:406:19)
    at writeOrBuffer (_stream_writable.js:394:5)
    at Socket.Writable.write (_stream_writable.js:294:11)
    at Interface._writeToOutput (readline.js:300:17)
    at Interface.prompt (readline.js:264:10)
    at Interface.question (readline.js:277:12)
    at worker (c:\Users\soegtrop\.vscode\extensions\freebroccolo.reasonml-1.0.38\node_modules\ocaml-language-server\bin\server\processes\merlin.js:52:31)
    at c:\Users\soegtrop\.vscode\extensions\freebroccolo.reasonml-1.0.38\node_modules\async\dist\async.js:4082:9
    at process (c:\Users\soegtrop\.vscode\extensions\freebroccolo.reasonml-1.0.38\node_modules\async\dist\async.js:2330:17)
    at Immediate.<anonymous> (c:\Users\soegtrop\.vscode\extensions\freebroccolo.reasonml-1.0.38\node_modules\async\dist\async.js:119:16)
Emitted 'error' event at:
    at onwriteError (_stream_writable.js:425:12)
    at onwrite (_stream_writable.js:456:5)
    at doWrite (_stream_writable.js:406:11)
    at writeOrBuffer (_stream_writable.js:394:5)
    [... lines matching original stack trace ...]
    at c:\Users\soegtrop\.vscode\extensions\freebroccolo.reasonml-1.0.38\node_modules\async\dist\async.js:4082:9
[Error - 10:24:01] Connection to server got closed. Server will not be restarted.
[Error - 10:24:01] Request textDocument/codeAction failed.
Error: Connection got disposed.
    at Object.dispose (C:\Users\soegtrop\.vscode\extensions\freebroccolo.reasonml-1.0.38\node_modules\vscode-jsonrpc\lib\main.js:825:25)
    at Object.dispose (C:\Users\soegtrop\.vscode\extensions\freebroccolo.reasonml-1.0.38\node_modules\vscode-languageclient\lib\client.js:57:35)
    at LanguageClient.handleConnectionClosed (C:\Users\soegtrop\.vscode\extensions\freebroccolo.reasonml-1.0.38\node_modules\vscode-languageclient\lib\client.js:1954:42)
    at LanguageClient.handleConnectionClosed (C:\Users\soegtrop\.vscode\extensions\freebroccolo.reasonml-1.0.38\node_modules\vscode-languageclient\lib\main.js:126:15)
    at closeHandler (C:\Users\soegtrop\.vscode\extensions\freebroccolo.reasonml-1.0.38\node_modules\vscode-languageclient\lib\client.js:1941:18)
    at CallbackList.invoke (C:\Users\soegtrop\.vscode\extensions\freebroccolo.reasonml-1.0.38\node_modules\vscode-jsonrpc\lib\events.js:71:39)
    at Emitter.fire (C:\Users\soegtrop\.vscode\extensions\freebroccolo.reasonml-1.0.38\node_modules\vscode-jsonrpc\lib\events.js:135:36)
    at closeHandler (C:\Users\soegtrop\.vscode\extensions\freebroccolo.reasonml-1.0.38\node_modules\vscode-jsonrpc\lib\main.js:221:26)
    at CallbackList.invoke (C:\Users\soegtrop\.vscode\extensions\freebroccolo.reasonml-1.0.38\node_modules\vscode-jsonrpc\lib\events.js:71:39)
    at Emitter.fire (C:\Users\soegtrop\.vscode\extensions\freebroccolo.reasonml-1.0.38\node_modules\vscode-jsonrpc\lib\events.js:135:36)
    at IPCMessageReader.AbstractMessageReader.fireClose (C:\Users\soegtrop\.vscode\extensions\freebroccolo.reasonml-1.0.38\node_modules\vscode-jsonrpc\lib\messageReader.js:135:27)
    at ChildProcess.<anonymous> (C:\Users\soegtrop\.vscode\extensions\freebroccolo.reasonml-1.0.38\node_modules\vscode-jsonrpc\lib\messageReader.js:253:61)
    at ChildProcess.emit (events.js:187:15)
    at maybeClose (internal/child_process.js:961:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
MSoegtropIMC commented 5 years ago

P.S.: If this helps, I can provide a set of CMD and bash scripts which exactly reproduce my environment from scratch, including setting up cygwin, opam and compiling Merlin for MinGW.

cqfllp commented 5 years ago

I just encountered the same problem. Same Windows 10.

mnxn commented 5 years ago

@MSoegtropIMC @cqfllp This sounds related to #236

Try setting reason.path.ocamlmerlin to "ocamlmerlin-server"

MSoegtropIMC commented 5 years ago

Thanks, indeed this works!

MSoegtropIMC commented 5 years ago

P.S.: There is one more caveat: I found that sometimes VSCode leaves hidden processes after closing and if it is started from the command line, it might pick up this hidden process rather than creating a new one. This has the effect that VSCode has the wrong environment, notably possibly a wrong path without ocamlmerlin-server. In case you have unreproducible errors, open a terminal from VSCode and inspect that PATH. If the PATH is wrong, close VSCode, check that there are no VSCode processes left (or kill them) and restart.