Skip to content

Commit df200f1

Browse files
hopehadfieldrgrunber
authored andcommitted
Display error status for OutOfMemory & consistent terminations
1 parent 71f02cc commit df200f1

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/clientErrorHandler.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { window, commands } from "vscode";
2+
import { serverStatusBarProvider } from './serverStatusBarProvider';
23
import { ErrorHandler, Message, ErrorAction, CloseAction, ErrorHandlerResult, CloseHandlerResult } from "vscode-languageclient";
34
import { Commands } from "./commands";
45
import { logger } from "./log";
@@ -36,6 +37,7 @@ export class ClientErrorHandler implements ErrorHandler {
3637
if (diff <= 3 * 60 * 1000) {
3738
const message = `The ${this.name} server crashed 5 times in the last 3 minutes. The server will not be restarted.`;
3839
logger.error(message);
40+
serverStatusBarProvider.setError();
3941
const action = "Show logs";
4042
window.showErrorMessage(message, action).then(selection => {
4143
if (selection === action) {

src/extension.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,11 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
242242
errorHandler: new ClientErrorHandler(extensionName),
243243
initializationFailedHandler: error => {
244244
logger.error(`Failed to initialize ${extensionName} due to ${error && error.toString()}`);
245-
return true;
245+
if (error.toString().includes('Connection') && error.toString().includes('disposed')) {
246+
return false;
247+
} else {
248+
return true;
249+
}
246250
},
247251
outputChannel: requireStandardServer ? new OutputInfoCollector(extensionName) : undefined,
248252
outputChannelName: extensionName
@@ -966,6 +970,7 @@ function registerOutOfMemoryDetection(storagePath: string) {
966970
fse.remove(path);
967971
}
968972
showOOMMessage();
973+
serverStatusBarProvider.setError();
969974
});
970975
}
971976

0 commit comments

Comments
 (0)