Skip to content

Commit 7ced1ed

Browse files
committed
Fix incorrect logger when a client error occurs
Previously, when the client failed to connect to the Language Server, e.g. the local language server crashes, the UI was not updated to say that it failed. This was due to an error being thrown in the error handler. This commit changes the connection handler to use the reference to the language client instead of, `this` which is a Socket object.
1 parent 144cfe2 commit 7ced1ed

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

client/src/connection.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ export class ConnectionManager implements IConnectionManager {
295295

296296
private startLangClientTCP(): LanguageClient {
297297
this.logger.debug('Configuring language server options')
298+
let langClient = this;
298299

299300
let connMgr:ConnectionManager = this;
300301
let serverOptions: ServerOptions = function () {
@@ -304,7 +305,7 @@ export class ConnectionManager implements IConnectionManager {
304305
resolve({ reader: client, writer: client });
305306
});
306307
client.on('error', function (err) {
307-
this.logger.error(`[Puppet Lang Server Client] ` + err);
308+
langClient.logger.error(`[Puppet Lang Server Client] ` + err);
308309
connMgr.setSessionFailure("Could not start language client: ", err.message);
309310

310311
return null;
@@ -322,7 +323,7 @@ export class ConnectionManager implements IConnectionManager {
322323
var title = `tcp lang server (host ${this.connectionConfiguration.host} port ${this.connectionConfiguration.port})`;
323324
var languageServerClient = new LanguageClient(title, serverOptions, clientOptions)
324325
languageServerClient.onReady().then(() => {
325-
this.logger.debug('Language server client started, setting puppet version')
326+
langClient.logger.debug('Language server client started, setting puppet version')
326327
languageServerClient.sendRequest(messages.PuppetVersionRequest.type).then((versionDetails) => {
327328
this.setConnectionStatus(versionDetails.puppetVersion, ConnectionStatus.Running);
328329
});

0 commit comments

Comments
 (0)