PowerShell extension doesn't stop powershell Integrated Console process when project is closed
See original GitHub issuePrerequisites
- 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
Every time I open new project folder, the PowerShell extension starts new PowerShell process. Closing folder doesn’t stop now redundant PowerShell process(es). Opening next project (folder), starts new process. Opening scirpt in separate VS Code window starts yet again new PowerShell process (and closing that window leaves PowerShell process running).
After switching between several projects, that makes quite some bit of memory.
The same occurred with PowerShell-Preview extension. It also doesn’t matter, which version of PowerShell is used by extension: Windows PowerShell 5.1 is loaded and left running the same way.
All processes are stopped, when last VS Code window will be closed.
PowerShell Version
PS ❯ $PSVersionTable
Name Value
---- -----
PSVersion 7.1.3
PSEdition Core
GitCommitId 7.1.3
OS Microsoft Windows 10.0.19042
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
PS ❯ code --version
1.58.2
c3f126316369cd610563c75b1b1725e0679adfb3
x64
Extension Version
PS ❯ code --list-extensions --show-versions | Select-String powershell
ms-vscode.powershell@2021.6.2 (enabled)
ms-vscode.powershell-preview@2021.7.0 (disabled)
Steps to Reproduce
- Open project containing PowerShell files. Have some PowerShell files opened (to get PowerShell extension started)
- Open another project (and some PowerShell files)
- Open code with .ps1 file from command line (
code -n file.ps1
)
Now there will be 3 PowerShell processes visible in VS Code Project Explorer and in Windows Task Manager.
Visuals
This is VS Code Process Explorer after opening 2 project folders and one file in separate window:
Logs
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:25 (12 by maintainers)
Top GitHub Comments
I wonder if this is related to https://github.com/PowerShell/vscode-powershell/issues/3360, so when we fix that bug, let’s test this again.
If this still happens after #3360 you could try the
Terminal: Attach to Session
command, if the process is classified as an “orphan” without a window you should be able to reattach to it.