Skip to content

Commit

Permalink
Fixes #286: LangaueClient#handleConnectionClosed fails to restart if …
Browse files Browse the repository at this point in the history
…this._resolvedConnection.dispose() throws
  • Loading branch information
dbaeumer committed Dec 7, 2017
1 parent b2a28e3 commit dfce081
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2740,12 +2740,21 @@ export abstract class BaseLanguageClient {
if (this.state === ClientState.Stopping || this.state === ClientState.Stopped) {
return;
}
if (this._resolvedConnection) {
this._resolvedConnection.dispose();
try {
if (this._resolvedConnection) {
this._resolvedConnection.dispose();
}
} catch (error) {
// Disposing a connection could fail if error cases.
}
let action = CloseAction.DoNotRestart;
try {
action = this._clientOptions.errorHandler!.closed();
} catch (error) {
// Ignore errors coming from the error handler.
}
this._connectionPromise = undefined;
this._resolvedConnection = undefined;
let action = this._clientOptions.errorHandler!.closed();
if (action === CloseAction.DoNotRestart) {
this.error('Connection to server got closed. Server will not be restarted.');
this.state = ClientState.Stopped;
Expand Down

0 comments on commit dfce081

Please sign in to comment.