question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PowerShell extension doesn't stop powershell Integrated Console process when project is closed

See original GitHub issue

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

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

  1. Open project containing PowerShell files. Have some PowerShell files opened (to get PowerShell extension started)
  2. Open another project (and some PowerShell files)
  3. 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: image

Logs

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:25 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
andschwacommented, Nov 9, 2021

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.

1reaction
Tyriarcommented, Mar 15, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stop-Process (Microsoft.PowerShell.Management)
This command stops all instances of the Notepad process on the computer. Each instance of Notepad runs in its own process. It uses...
Read more >
Visual Studio (VS-code) code terminal is failing to launch
Go to the setting of Visual Studio Code and disable this property powershell.integratedConsole.suppressStartupBanner. It worked for me ...
Read more >
Debugging in Visual Studio Code
One of the great things in Visual Studio Code is debugging support. Set breakpoints, step-in, inspect variables and more.
Read more >
Fix for PowerShell Script cannot be loaded because running ...
This is due to the Windows PowerShell execution policy being set to prevent untrusted scripts which can affect your Windows client environment.
Read more >
How does the batch file work in PowerShell? - eduCBA
A batch file is a series of commands or a script in the Windows Operating System or in DOS which can run a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found