sfodje / perlcritic

MIT License
5 stars 4 forks source link

Error: Call listen() first #15

Open wbudic opened 5 years ago

wbudic commented 5 years ago

Getting server crashing, output:

Error: Call listen() first. at throwIfNotListening (/home/will/.vscode/extensions/sfodje.perlcritic-1.0.2/server/node_modules/vscode-jsonrpc/lib/main.js:626:19) at Object.sendRequest (/home/will/.vscode/extensions/sfodje.perlcritic-1.0.2/server/node_modules/vscode-jsonrpc/lib/main.js:716:13) at Object.sendRequest (/home/will/.vscode/extensions/sfodje.perlcritic-1.0.2/server/node_modules/vscode-languageserver/lib/main.js:737:54) at RemoteWindowImpl.showErrorMessage (/home/will/.vscode/extensions/sfodje.perlcritic-1.0.2/server/node_modules/vscode-languageserver/lib/main.js:407:33) at validateExecutable (/home/will/.vscode/extensions/sfodje.perlcritic-1.0.2/server/out/server.js:89:27) at Object. (/home/will/.vscode/extensions/sfodje.perlcritic-1.0.2/server/out/server.js:66:17) at Object. (/home/will/.vscode/extensions/sfodje.perlcritic-1.0.2/server/out/server.js:266:3) at Module._compile (internal/modules/cjs/loader.js:693:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:704:10) at Module.load (internal/modules/cjs/loader.js:602:32) [Info - 2:23:54 am] Connection to server got closed. Server will restart. /home/will/.vscode/extensions/sfodje.perlcritic-1.0.2/server/node_modules/vscode-jsonrpc/lib/main.js:626 throw new Error('Call listen() first.');

DanFreed commented 4 years ago

For anyone that hits this issue, to work around it modify your path so that "which perlcritic" can resolve perlcriitic. The error is occurring because when it is not in your path, the server extension is validating it can find it as part of its default settings. If it cannot it issues:

connection.window.showErrorMessage(error);

This will trigger the error you are seeing.

DanFreed commented 4 years ago

Fix:

diff --git a/server/src/server.ts b/server/src/server.ts index f4f29bf..ea3d575 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -104,6 +104,7 @@ connection.onDidChangeConfiguration(change => { try { globalSettings = mergeSettings(change.settings.perlcritic); } catch (error) {

@@ -116,7 +117,7 @@ function validateExecutable(executable: string): string { return which.sync(executable); } catch (error) {