From e18bc5ada39db8aaa1ecc4621bf89c64d1e129f0 Mon Sep 17 00:00:00 2001 From: Rob Holt Date: Tue, 25 Feb 2020 13:54:45 -0800 Subject: [PATCH 1/2] Move terminal PID log to a non-awaited callback --- src/process.ts | 8 ++++++-- src/session.ts | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/process.ts b/src/process.ts index ba945aaa49..05a75673de 100644 --- a/src/process.ts +++ b/src/process.ts @@ -122,9 +122,9 @@ export class PowerShellProcess { this.consoleCloseSubscription = vscode.window.onDidCloseTerminal((terminal) => this.onTerminalClose(terminal)); // Log that the PowerShell terminal process has been started - const terminalPid = await this.consoleTerminal.processId; const pwshName = path.basename(this.exePath); - this.log.write(`${pwshName} started, pid: ${terminalPid}`); + this.consoleTerminal.processId.then((pid) => this.logTerminalPid(pid, pwshName)); + this.log.write(`${pwshName} started.`); return sessionDetails; } @@ -152,6 +152,10 @@ export class PowerShellProcess { } } + private logTerminalPid(pid: number, exeName: string) { + this.log.write(`${exeName} PID: ${pid}`); + } + private isLoginShell(pwshPath: string): boolean { try { // We can't know what version of PowerShell we have without running it diff --git a/src/session.ts b/src/session.ts index 145ecfbd00..10e4de6a3f 100644 --- a/src/session.ts +++ b/src/session.ts @@ -458,7 +458,11 @@ export class SessionManager implements Middleware { this.log.write("Language server startup failed."); this.setSessionFailure("The language service could not be started: ", error); }, - ); + ) + .catch((error) => { + this.log.write("Language server startup failed."); + this.setSessionFailure("The language server could not be started: ", error); + }); } private promptForRestart() { From 99228d8c7145a55c165a2f2bfb52af7d9696906f Mon Sep 17 00:00:00 2001 From: Rob Holt Date: Tue, 25 Feb 2020 15:44:02 -0800 Subject: [PATCH 2/2] Add logging to startup --- src/process.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/process.ts b/src/process.ts index 05a75673de..aa957b5dd3 100644 --- a/src/process.ts +++ b/src/process.ts @@ -110,21 +110,25 @@ export class PowerShellProcess { hideFromUser: !this.sessionSettings.integratedConsole.showOnStartup, }); + const pwshName = path.basename(this.exePath); + this.log.write(`${pwshName} started.`); + if (this.sessionSettings.integratedConsole.showOnStartup) { // We still need to run this to set the active terminal to the Integrated Console. this.consoleTerminal.show(true); } // Start the language client + this.log.write("Waiting for session file"); const sessionDetails = await this.waitForSessionFile(); // Subscribe a log event for when the terminal closes + this.log.write("Registering terminal close callback"); this.consoleCloseSubscription = vscode.window.onDidCloseTerminal((terminal) => this.onTerminalClose(terminal)); // Log that the PowerShell terminal process has been started - const pwshName = path.basename(this.exePath); + this.log.write("Registering terminal PID log callback"); this.consoleTerminal.processId.then((pid) => this.logTerminalPid(pid, pwshName)); - this.log.write(`${pwshName} started.`); return sessionDetails; } @@ -176,9 +180,11 @@ export class PowerShellProcess { utils.deleteSessionFile(this.sessionFilePath); if (error) { + this.log.write("Error occurred retrieving session file"); return reject(error); } + this.log.write("Session file found"); resolve(sessionDetails); }); });