Description
Prerequisites
- I have written a descriptive issue title.
- I have searched all issues to ensure it has not already been reported.
- I have read the troubleshooting guide.
- I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
Summary
In the exported deactivate()
function, it first calls to all languageClientConsumers
' dispose()
. I noticed that two of them are throwing error, and preventing the rest of the deactivate()
logic from running (e.g. the session manager's stop()
is never run).
The two offenders are ShowHelp and DebugSession. The common reason of their failure is that, in the ts file a command variable is declared but never assigned. When the ts is compiled to js file, these variables got omitted. Therefore, when the consumer's dispose() tries to dispose these command variables, variable can't be found.
For example, ShowHelpFeature has a deprecatedCommand
. It is accessed here. Here is the relevant part of the js file from vsix:
...
constructor(log) {
super();
this.log = log;
this.command = vscode.commands.registerCommand("PowerShell.ShowHelp", (item) => {
if (!item || !item.Name) {
...
}
dispose() {
this.command.dispose();
this.deprecatedCommand.dispose();
}
}
The one from DebugSession is this one.
If I comment out the dispose()
calls in the installed js file, I can verify from log file that things are back to work (these two lines are currently missing):
9/24/2021 6:49:23 AM [NORMAL] - Shutting down language client...
9/24/2021 6:49:23 AM [NORMAL] - Terminating PowerShell process...
PowerShell Version
Name Value
---- -----
PSVersion 7.1.4
PSEdition Core
GitCommitId 7.1.4
OS Microsoft Windows 10.0.19043
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visual Studio Code Version
1.60.2
7f6ab5485bbc008386c4386d08766667e155244e
x64
Extension Version
ms-vscode.powershell@2021.9.0
Steps to Reproduce
- Install the extension
- Open an ps1 file, wait for a few seconds
- Close VSCode
- Look at the log file
Visuals
No response
Logs
Current:
9/24/2021 6:54:35 AM [NORMAL] - Language server starting --
9/24/2021 6:54:35 AM [NORMAL] - PowerShell executable: <redacted>\pwsh\current\pwsh.exe
9/24/2021 6:54:35 AM [NORMAL] - pwsh.exe started.
9/24/2021 6:54:35 AM [NORMAL] - Waiting for session file
9/24/2021 6:54:35 AM [NORMAL] - PowerShell Editor Services args: Import-Module '<redacted>\vscode\data\extensions\ms-vscode.powershell-2021.9.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2021.9.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath '<redacted>\vscode\data\extensions\ms-vscode.powershell-2021.9.0\modules' -EnableConsoleRepl -StartupBanner '' -LogLevel 'Normal' -LogPath '<redacted>\vscode\data\extensions\ms-vscode.powershell-2021.9.0\logs\1632491675-0e14938c-3cc1-4020-b3c2-a6bc8bac2b1a1632491673928\EditorServices.log' -SessionDetailsPath '<redacted>\vscode\data\extensions\ms-vscode.powershell-2021.9.0\sessions\PSES-VSCode-10176-190235' -FeatureFlags @()
9/24/2021 6:54:35 AM [NORMAL] - PowerShell args: -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command Import-Module '<redacted>\vscode\data\extensions\ms-vscode.powershell-2021.9.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2021.9.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath '<redacted>\vscode\data\extensions\ms-vscode.powershell-2021.9.0\modules' -EnableConsoleRepl -StartupBanner '' -LogLevel 'Normal' -LogPath '<redacted>\vscode\data\extensions\ms-vscode.powershell-2021.9.0\logs\1632491675-0e14938c-3cc1-4020-b3c2-a6bc8bac2b1a1632491673928\EditorServices.log' -SessionDetailsPath '<redacted>\vscode\data\extensions\ms-vscode.powershell-2021.9.0\sessions\PSES-VSCode-10176-190235' -FeatureFlags @()
9/24/2021 6:54:37 AM [NORMAL] - Session file found
9/24/2021 6:54:37 AM [NORMAL] - Registering terminal close callback
9/24/2021 6:54:37 AM [NORMAL] - Registering terminal PID log callback
9/24/2021 6:54:37 AM [NORMAL] - pwsh.exe PID: 14764
9/24/2021 6:54:37 AM [NORMAL] - {"status":"started","languageServiceTransport":"NamedPipe","languageServicePipeName":"\\\\.\\pipe\\PSES_40lewdxk.4yb","debugServiceTransport":"NamedPipe","debugServicePipeName":"\\\\.\\pipe\\PSES_kabzcodf.m3n"}
9/24/2021 6:54:37 AM [NORMAL] - Language server started.
9/24/2021 6:54:37 AM [NORMAL] - Language service connected.
9/24/2021 6:54:37 AM [NORMAL] - Connecting to language service on pipe \\.\pipe\PSES_40lewdxk.4yb...
After my local fix:
9/24/2021 6:55:42 AM [NORMAL] - Language server starting --
9/24/2021 6:55:42 AM [NORMAL] - PowerShell executable: <redacted>\pwsh\current\pwsh.exe
9/24/2021 6:55:42 AM [NORMAL] - pwsh.exe started.
9/24/2021 6:55:42 AM [NORMAL] - Waiting for session file
9/24/2021 6:55:42 AM [NORMAL] - PowerShell args: -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command Import-Module '<redacted>\vscode\data\extensions\ms-vscode.powershell-2021.9.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2021.9.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath '<redacted>\vscode\data\extensions\ms-vscode.powershell-2021.9.0\modules' -EnableConsoleRepl -StartupBanner '' -LogLevel 'Normal' -LogPath '<redacted>\vscode\data\extensions\ms-vscode.powershell-2021.9.0\logs\1632491742-bbb95136-8abe-4aa3-9b77-77978365b52e1632491741204\EditorServices.log' -SessionDetailsPath '<redacted>\vscode\data\extensions\ms-vscode.powershell-2021.9.0\sessions\PSES-VSCode-3188-935947' -FeatureFlags @()
9/24/2021 6:55:42 AM [NORMAL] - PowerShell Editor Services args: Import-Module '<redacted>\vscode\data\extensions\ms-vscode.powershell-2021.9.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2021.9.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath '<redacted>\vscode\data\extensions\ms-vscode.powershell-2021.9.0\modules' -EnableConsoleRepl -StartupBanner '' -LogLevel 'Normal' -LogPath '<redacted>\vscode\data\extensions\ms-vscode.powershell-2021.9.0\logs\1632491742-bbb95136-8abe-4aa3-9b77-77978365b52e1632491741204\EditorServices.log' -SessionDetailsPath '<redacted>\vscode\data\extensions\ms-vscode.powershell-2021.9.0\sessions\PSES-VSCode-3188-935947' -FeatureFlags @()
9/24/2021 6:55:44 AM [NORMAL] - Session file found
9/24/2021 6:55:44 AM [NORMAL] - Registering terminal close callback
9/24/2021 6:55:44 AM [NORMAL] - Registering terminal PID log callback
9/24/2021 6:55:44 AM [NORMAL] - Language server started.
9/24/2021 6:55:44 AM [NORMAL] - {"status":"started","languageServiceTransport":"NamedPipe","languageServicePipeName":"\\\\.\\pipe\\PSES_x0artraj.suh","debugServiceTransport":"NamedPipe","debugServicePipeName":"\\\\.\\pipe\\PSES_huxxuiys.jgi"}
9/24/2021 6:55:44 AM [NORMAL] - Connecting to language service on pipe \\.\pipe\PSES_x0artraj.suh...
9/24/2021 6:55:44 AM [NORMAL] - pwsh.exe PID: 14076
9/24/2021 6:55:44 AM [NORMAL] - Language service connected.
9/24/2021 6:55:45 AM [NORMAL] - Shutting down language client...
9/24/2021 6:55:45 AM [NORMAL] - Terminating PowerShell process...