vscode-powershell icon indicating copy to clipboard operation
vscode-powershell copied to clipboard

extensionHost running dozens of pwsh -c "Get-Command -All"

Open SOM-Scott opened this issue 8 months ago • 2 comments

Prerequisites

  • [x] I have written a descriptive issue title.
  • [x] I have searched all open and closed issues to ensure it has not already been reported.
  • [x] I have read the troubleshooting guide.
  • [x] I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • [x] I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • [ ] If this is a security issue, I have read the security issue reporting guidance.

Summary

There are often well over 15 extensionHost processes running pwsh -c "Get-Command -All" which lags out my system, each one taking 5-10% CPU.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.5.0
PSEdition                      Core
GitCommitId                    7.5.0
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Name             : Visual Studio Code Host
Version          : 2025.0.0
InstanceId       : e708609b-6fff-4686-b3c4-3dcb1d390b8f
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Visual Studio Code Version

1.99.0
4437686ffebaf200fa4a6e6e67f735f3edf24ada
x64

Extension Version

[email protected]

Steps to Reproduce

Open VS Code Open ps1 file Start typing

Visuals

No response

Logs

Of course I am unable to reproduce after enabling trace logging.

SOM-Scott avatar Apr 08 '25 16:04 SOM-Scott

Thanks for your submission!

Do you have the PowerShell Command window enabled? That could be a potential culprit, but there should only ever be one. That particular component is deprecated. I'm unable to reproduce it.

JustinGrote avatar Apr 08 '25 22:04 JustinGrote

Does this happen with your profile disabled?

SydneyhSmith avatar Apr 29 '25 18:04 SydneyhSmith

I'm also hitting the same issue on MS cloud PC. How do I pull the logs for you?

JasonDTX avatar Jun 30 '25 21:06 JasonDTX

I'm having the same experience. It does not matter if powershell.enableProfileLoading is enabled or not.

Name                           Value
----                           -----
PSVersion                      7.5.2
PSEdition                      Core
GitCommitId                    7.5.2
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

1.102.0-insider
d6b261f44406fdd26e5c0de997fe8e30d7fae5d7
x64

[email protected]

Major  Minor  Build  Revision
-----  -----  -----  --------
4      3      0      0

Commands I've noticed running: pwsh -c "Get-Command -All | Select-Object Name, CommandType, Definition, ModuleName, @{Name=\"Version\";Expression={$_.Version.ToString()}} | ConvertTo-Json" pwsh -c "Get-Command -CommandType Alias | Select-Object Name, CommandType, Definition, DisplayName, ModuleName, @{Name=\"Version\";Expression={$_.Version.ToString()}} | ConvertTo-Json"

However, it seems that disabling Terminal > Integrated > Suggest: Enable (Preview) prevents the problem from arising.

Dylan-Carlson-COS avatar Jul 08 '25 21:07 Dylan-Carlson-COS

@andyleejordan I know you did some coordination with the VSCode team on the Suggest stuff (which is not part of this extension), does this ring a bell? I imagine it's to populate the terminal intellisense.

JustinGrote avatar Jul 08 '25 21:07 JustinGrote

Yeah that does ring a bell. Let's loop in @Tyriar.

andyleejordan avatar Jul 10 '25 19:07 andyleejordan

Yup, found it: https://github.com/microsoft/vscode/blob/d2b3e0a3d6c0002d83351786adf0abe6e14d16de/extensions/terminal-suggest/src/shell/pwsh.ts#L58

@Tyriar maybe we can transfer this issue to your repo?

andyleejordan avatar Jul 10 '25 19:07 andyleejordan

This issue has been labeled as resolved, please verify the provided fix (or other reason).

github-actions[bot] avatar Jul 10 '25 20:07 github-actions[bot]

This shouldn't be locking up extension hosts as most of it is async waiting. We also tweaked caching to be much more aggressively recently. FYI @meganrogge

Tyriar avatar Jul 15 '25 20:07 Tyriar

This issue has been labeled as resolved, please verify the provided fix (or other reason).

github-actions[bot] avatar Jul 15 '25 21:07 github-actions[bot]

More info: https://github.com/microsoft/vscode/issues/256746#issuecomment-3102748099

Tyriar avatar Jul 22 '25 13:07 Tyriar

This issue has been labeled as resolved, please verify the provided fix (or other reason).

github-actions[bot] avatar Jul 22 '25 15:07 github-actions[bot]

This issue has been labeled as resolved, please verify the provided fix (or other reason).

github-actions[bot] avatar Jul 22 '25 17:07 github-actions[bot]

Going to mark it here as a dupe of the external issue that has been opened, please track there.

JustinGrote avatar Jul 29 '25 17:07 JustinGrote