diff --git a/src/process.ts b/src/process.ts index 824c7740ca..6cc291e977 100644 --- a/src/process.ts +++ b/src/process.ts @@ -15,7 +15,7 @@ export class PowerShellProcess { private static warnUserThreshold = 30; public onExited: vscode.Event; - private onExitedEmitter = new vscode.EventEmitter(); + private onExitedEmitter?: vscode.EventEmitter; private consoleTerminal?: vscode.Terminal; private consoleCloseSubscription?: vscode.Disposable; @@ -31,6 +31,7 @@ export class PowerShellProcess { private sessionFilePath: vscode.Uri, private sessionSettings: Settings) { + this.onExitedEmitter = new vscode.EventEmitter(); this.onExited = this.onExitedEmitter.event; } @@ -149,6 +150,9 @@ export class PowerShellProcess { void this.deleteSessionFile(this.sessionFilePath); + this.onExitedEmitter?.fire(); + this.onExitedEmitter = undefined; + this.consoleTerminal?.dispose(); this.consoleTerminal = undefined; @@ -230,7 +234,6 @@ export class PowerShellProcess { } this.logger.writeWarning(`PowerShell process terminated or Extension Terminal was closed, PID: ${this.pid}`); - this.onExitedEmitter.fire(); this.dispose(); } } diff --git a/src/session.ts b/src/session.ts index 866117316a..3123792a51 100644 --- a/src/session.ts +++ b/src/session.ts @@ -530,13 +530,13 @@ export class SessionManager implements Middleware { this.sessionSettings); languageServerProcess.onExited( - async () => { + () => { LanguageClientConsumer.onLanguageClientExited(); if (this.sessionStatus === SessionStatus.Running || this.sessionStatus === SessionStatus.Busy) { this.setSessionStatus("Session Exited!", SessionStatus.Failed); - await this.promptForRestart(); + void this.promptForRestart(); } });