Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language Server Becomes Unresponsive After Opening Command Explorer #4992

Open
6 tasks done
andria-dev opened this issue May 18, 2024 · 2 comments
Open
6 tasks done
Labels
Area-Command Explorer Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed!

Comments

@andria-dev
Copy link

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • 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

PowerShell intellisense works until I open the command explorer once. The command explorer never populates, and I have to close the command explorer and restart the PowerShell session to get intellisense working again.

PowerShell Version

PS> $PSVersionTable; $Host                                                                                                                                                                                             

Name                           Value
----                           -----
PSVersion                      7.4.2
PSEdition                      Core
GitCommitId                    7.4.2
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          : 2024.2.2
InstanceId       : 99850762-31fb-4299-8d83-da801db98e37
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

PS> code --version                                                                                                                                                                                                     
1.89.1
dc96b837cf6bb4af9
x64

Extension Version

PS> code --list-extensions --show-versions | sls powershell                                                                                                                                                            

[email protected]

Steps to Reproduce

  1. Open a folder as a workspace.
  2. Create a PowerShell script.
  3. Type in the first half of a command.
  4. See intellisense working (or press Ctrl + Space to trigger it).
  5. Open PowerShell Command Explorer.
  6. Click on the end of the command you were just typing.
  7. Press Ctrl + Space to trigger intellisense.
  8. See indefinite "Loading..." status.

Visuals

Recording.2024-05-17.234022.mp4

Logs

PowerShell Editor Services Client logs just after opening Command Explorer

[Trace - 11:17:18 PM] Sending request 'powerShell/getCommand - (15)'.
[Trace - 11:17:18 PM] Received notification 'window/logMessage'.
Params: {
    "type": 4,
    "message": "OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter: Finding descriptors for powerShell/getCommand | Method='powerShell/getCommand'"
}


OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter: Finding descriptors for powerShell/getCommand | Method='powerShell/getCommand'
[Trace - 11:17:18 PM] Received notification 'window/logMessage'.
Params: {
    "type": 4,
    "message": "OmniSharp.Extensions.JsonRpc.ProcessScheduler: Queueing Serial:powerShell/getCommand:15 request for processing | Type='Serial' Name='powerShell/getCommand:15'"
}


OmniSharp.Extensions.JsonRpc.ProcessScheduler: Queueing Serial:powerShell/getCommand:15 request for processing | Type='Serial' Name='powerShell/getCommand:15'
[Trace - 11:17:18 PM] Received notification 'window/logMessage'.
Params: {
    "type": 4,
    "message": "OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker: Starting: Processing request powerShell/getCommand 15 | Method='powerShell/getCommand' ResponseId='15'"
}


OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker: Starting: Processing request powerShell/getCommand 15 | Method='powerShell/getCommand' ResponseId='15'
[Trace - 11:17:18 PM] Received notification 'window/logMessage'.
Params: {
    "type": 4,
    "message": "OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter: Starting: Routing Request (15) powerShell/getCommand | Id='15' Method='powerShell/getCommand'"
}


OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter: Starting: Routing Request (15) powerShell/getCommand | Id='15' Method='powerShell/getCommand'
[Trace - 11:17:18 PM] Received notification 'window/logMessage'.
Params: {
    "type": 4,
    "message": "OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter: Converting params for Request (15) powerShell/getCommand to Microsoft.PowerShell.EditorServices.Handlers.GetCommandParams | Id='15' Method='powerShell/getCommand' Type='Microsoft.PowerShell.EditorServices.Handlers.GetCommandParams'"
}


OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter: Converting params for Request (15) powerShell/getCommand to Microsoft.PowerShell.EditorServices.Handlers.GetCommandParams | Id='15' Method='powerShell/getCommand' Type='Microsoft.PowerShell.EditorServices.Handlers.GetCommandParams'
[Trace - 11:17:18 PM] Received notification 'window/logMessage'.
Params: {
    "type": 4,
    "message": "OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter: Converting params for Notification powerShell/getCommand to Microsoft.PowerShell.EditorServices.Handlers.GetCommandParams | Method='powerShell/getCommand' Type='Microsoft.PowerShell.EditorServices.Handlers.GetCommandParams'"
}


OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter: Converting params for Notification powerShell/getCommand to Microsoft.PowerShell.EditorServices.Handlers.GetCommandParams | Method='powerShell/getCommand' Type='Microsoft.PowerShell.EditorServices.Handlers.GetCommandParams'
[Trace - 11:17:18 PM] Received notification 'window/logMessage'.
Params: {
    "type": 4,
    "message": "OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter: Response value was System.Collections.Generic.List`1[[Microsoft.PowerShell.EditorServices.Handlers.PSCommandMessage, Microsoft.PowerShell.EditorServices, Version=3.20.1.0, Culture=neutral, PublicKeyToken=null]] | Type='System.Collections.Generic.List`1[[Microsoft.PowerShell.EditorServices.Handlers.PSCommandMessage, Microsoft.PowerShell.EditorServices, Version=3.20.1.0, Culture=neutral, PublicKeyToken=null]]'"
}


OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter: Response value was System.Collections.Generic.List`1[[Microsoft.PowerShell.EditorServices.Handlers.PSCommandMessage, Microsoft.PowerShell.EditorServices, Version=3.20.1.0, Culture=neutral, PublicKeyToken=null]] | Type='System.Collections.Generic.List`1[[Microsoft.PowerShell.EditorServices.Handlers.PSCommandMessage, Microsoft.PowerShell.EditorServices, Version=3.20.1.0, Culture=neutral, PublicKeyToken=null]]'
[Trace - 11:17:18 PM] Received notification 'window/logMessage'.
Params: {
    "type": 4,
    "message": "OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter: Finished: Routing Request (15) powerShell/getCommand in 382ms | Id='15' Method='powerShell/getCommand' ElapsedMilliseconds='382'"
}


OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter: Finished: Routing Request (15) powerShell/getCommand in 382ms | Id='15' Method='powerShell/getCommand' ElapsedMilliseconds='382'
[Trace - 11:17:18 PM] Received notification 'window/logMessage'.
Params: {
    "type": 4,
    "message": "OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker: Finished: Processing request powerShell/getCommand 15 in 382ms | Method='powerShell/getCommand' ResponseId='15' ElapsedMilliseconds='382'"
}


OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker: Finished: Processing request powerShell/getCommand 15 in 382ms | Method='powerShell/getCommand' ResponseId='15' ElapsedMilliseconds='382'

It will then send a textDocument/completion message when I do Ctrl + Space, but it will never receive any response, even after several minutes of waiting.

@andria-dev andria-dev added Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed! labels May 18, 2024
@SydneyhSmith SydneyhSmith added Area-Command Explorer and removed Needs: Triage Maintainer attention needed! labels May 22, 2024
@Grosner300
Copy link

Grosner300 commented Jul 8, 2024

I see same issue. Command Explorer never populates. When I run code.exe as different user, on same computer, Command Explorer and Intellisense work as expected.

After removing the Environment variable “Path” element, pointing to a folder containing PowerShell scripts, the Command Explorer and Intellisense worked as expected.

Additional information:
See: Script Content Triggers unhandled Newtonsoft.Json.JsonSerializationException #2165

The root cause appears to be caused by the actual script code I included in my PowerShell script as outlined in the above issue.
Rewriting the code fixes the issue.

win 11, Powershell 7.4.3, vscode 1.9.0, powershell extension 2024.2.2.

@TMA-2
Copy link
Contributor

TMA-2 commented Dec 1, 2024

Thanks for creating this issue. I've been having the same problem for months now (possibly up to a year) across four machines both work and personal, including VMs, three operating systems, probably 7+ minor versions of VSCode, other forks including VSCodium, Cursor, PearAI, etc. since (I think) about v2024.2.0 of the extension. However, the issue has followed me across disabling my PS profile, creating a new empty VSCode profile with only the PS extension installed, excluding every module in ⚙️powershell.sideBar.CommandExplorerExcludeFilter, and it freezes every. single. time. until I disable it again (at least there's that option!)

I'd love for this to be fixed so the feature could be improved, because I feel like one of the biggest things lacking in the PowerShell world is a robust visual help system. Obviously between Get-Help, Get-Command, MAML, PlatyPS, the online documentation, etc. it's not at all hard to get where you need, but a simple searchable, sortable TreeView (grouped by module and noun, perhaps?) that displays the online Markdown help inside a VS Code browser view would be incredible.

I have zero JS/TS knowledge, so for a minute I thought I found a possible solution through the PowerShell Pro Tools extension, which exposes a custom TreeView with invokable items... a radical idea in theory but unfortunately it's half-broken itself, never populating correctly, if at all, and likely won't be fixed since it's been sunsetted so the company can work more on Universal. so that didn't pan out..

I'm rambling now, but if I can help in any way with testing, I'd be quite happy to!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Command Explorer Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed!
Projects
None yet
Development

No branches or pull requests

5 participants