nwolverson/atom-ide-purescript

Connection Error when restarting IDE Server

georgevarghese185 opened this issue · 8 comments

After a while of using atom, ide-purescript stops working. It stops giving any suggestions/autocomplete/everything. Normally I'd just go to Packages > PureScript > Restart IDE Server and that would fix it. But I just recently (yesterday) updated ide-purescript to 0.22.0, so now, when I try restarting the IDE Server atom shows this error

Error: Connection is disposed. 
at new ConnectionError (/Users/george.varghese/.atom/packages/ide-purescript/node_modules/vscode-jsonrpc/lib/main.js:138:28) 
at throwIfClosedOrDisposed (/Users/george.varghese/.atom/packages/ide-purescript/node_modules/vscode-jsonrpc/lib/main.js:616:19) 
at Object.sendRequest (/Users/george.varghese/.atom/packages/ide-purescript/node_modules/vscode-jsonrpc/lib/main.js:715:13) 
at LanguageClientConnection._sendRequest (/Users/george.varghese/.atom/packages/ide-purescript/node_modules/atom-languageclient/build/lib/languageclient.js:400:34) 
at LanguageClientConnection.executeCommand (/Users/george.varghese/.atom/packages/ide-purescript/node_modules/atom-languageclient/build/lib/languageclient.js:367:17) 
at exports.executeCommandImpl (/Users/george.varghese/.atom/packages/ide-purescript/lib/main.js:6164:23) 
at /Users/george.varghese/.atom/packages/ide-purescript/lib/main.js:1143:18 
at /Users/george.varghese/.atom/packages/ide-purescript/lib/main.js:3464:18 
at /Users/george.varghese/.atom/packages/ide-purescript/lib/main.js:3381:19 
at /Users/george.varghese/.atom/packages/ide-purescript/lib/main.js:3428:22 
at /Users/george.varghese/.atom/packages/ide-purescript/lib/main.js:1052:18 
at /Users/george.varghese/.atom/packages/ide-purescript/lib/main.js:1052:22 
at HTMLElement. (/Users/george.varghese/.atom/packages/ide-purescript/lib/main.js:1121:19) 
at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:384:49) 
at CommandRegistry.dispatch (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:273:23) 
at AtomEnvironment.dispatchApplicationMenuCommand (/Applications/Atom.app/Contents/Resources/app/src/atom-environment.js:1343:25) 
at EventEmitter.outerCallback (/Applications/Atom.app/Contents/Resources/app/src/application-delegate.js:339:53) 
at emitThree (events.js:116:13) 
at EventEmitter.emit (events.js:197:7)

Restarting my entire system was the only thing that fixed it. But eventually the same thing would happen again. I'd stop getting Purescript suggestions and autocomplete, I'd try restarting the IDE Server and this error would show up. Any idea what's happening?

Hmm, looks like the language server itself has died instead of the purs ide server, I wonder why.

To diagnose I can only suggest looking in the developer console, & running atom.config.set('core.debugLSP', true) (prior to triggering the issue...)

Is there a way to tell ide-purescript to connect to a port of an already running purescript ide server I started (using pulp server)?

pulp server does not start an ide server. It starts an http server serving the JS the compiler ends up compiling. Why do you want to start the ide server yourself?

@kritzcreek Oh didn't know that. It's not necessary, it's just that I'm using atom in windows but I was experimenting using ubuntu inside Windows Subsystem For Linux to do all purescript and npm builds. So I wanted to know if I could run a server inside the WSL and have the atom ide purescript plugin talk to that.

Okay, well you can try that but then you need to start purs ide server pass it the proper globs and start it on the port specified in the .psc-ide-port file so atom can find it.

See https://github.com/purescript/purescript/tree/v0.11.7/psc-ide for how to start the ide server

Regarding the actual issue, it turns out this isn't to do with "Restart IDE Server" so much as any command after closing the last open .purs file being broken - as by atom-languageclient this should close the LSP server (but something isn't cleaned up properly).

I think this should be fixed in 0.23.1. Additionally the port is configurable - but since config in atom is all global without additional extensions, it's usually a bad idea in case you ever have 2 projects open at once.