Skip to content

Update language-client to 8.1.0 #2377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 56 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"virtualWorkspaces": false
},
"engines": {
"vscode": "^1.65.0"
"vscode": "^1.67.0"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -1400,7 +1400,7 @@
"@types/node": "^8.10.51",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since VS Code has switched to node 16 since 1.66 (https://code.visualstudio.com/updates/v1_66#_nodemoduleversion-and-nodejs-api-update), let's update this deps as well. The update will resolve the following error:

node_modules/vscode-jsonrpc/lib/node/main.d.ts(8,37): error TS2307: Cannot find module 'worker_threads' or its corresponding type declarations.

"@types/semver": "^7.3.8",
"@types/sinon": "^10.0.12",
"@types/vscode": "^1.65.0",
"@types/vscode": "^1.67.0",
"@types/winreg": "^1.2.30",
"@types/winston": "^2.4.4",
"@vscode/test-electron": "^2.1.5",
Expand Down Expand Up @@ -1431,7 +1431,7 @@
"htmlparser2": "6.0.1",
"jdk-utils": "^0.4.4",
"semver": "^7.3.5",
"vscode-languageclient": "7.1.0-next.5",
"vscode-languageclient": "8.1.0",
"winreg-utf8": "^0.1.1",
"winston": "^3.2.1",
"winston-daily-rotate-file": "^3.10.0"
Expand Down
26 changes: 18 additions & 8 deletions src/clientErrorHandler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { window, commands } from "vscode";
import { ErrorHandler, Message, ErrorAction, CloseAction } from "vscode-languageclient";
import { ErrorHandler, Message, ErrorAction, CloseAction, ErrorHandlerResult, CloseHandlerResult } from "vscode-languageclient";
import { Commands } from "./commands";
import { logger } from "./log";

Expand All @@ -10,21 +10,27 @@ export class ClientErrorHandler implements ErrorHandler {
this.restarts = [];
}

public error(_error: Error, _message: Message, count: number): ErrorAction {
public error(_error: Error, _message: Message, count: number): ErrorHandlerResult {
if (count && count <= 3) {
logger.error(`${this.name} server encountered error: ${_message}, ${_error && _error.toString()}`);
return ErrorAction.Continue;
return {
action: ErrorAction.Continue
};
}

logger.error(`${this.name} server encountered error and will shut down: ${_message}, ${_error && _error.toString()}`);
return ErrorAction.Shutdown;
return {
action: ErrorAction.Shutdown
};
}

public closed(): CloseAction {
public closed(): CloseHandlerResult {
this.restarts.push(Date.now());
if (this.restarts.length < 5) {
logger.error(`The ${this.name} server crashed and will restart.`);
return CloseAction.Restart;
return {
action: CloseAction.Restart
};
} else {
const diff = this.restarts[this.restarts.length - 1] - this.restarts[0];
if (diff <= 3 * 60 * 1000) {
Expand All @@ -36,12 +42,16 @@ export class ClientErrorHandler implements ErrorHandler {
commands.executeCommand(Commands.OPEN_LOGS);
}
});
return CloseAction.DoNotRestart;
return {
action: CloseAction.DoNotRestart
};
}

logger.error(`The ${this.name} server crashed and will restart.`);
this.restarts.shift();
return CloseAction.Restart;
return {
action: CloseAction.Restart
};
}
}
}
Loading