ironmansoftware / powershell-pro-tools

Scripting, automation, and development tools for professionals working with PowerShell.
MIT License
60 stars 3 forks source link

PowerShell Pro Tools is still starting. #1

Closed dragonwarrior00 closed 2 months ago

dragonwarrior00 commented 3 months ago

Describe the bug When launching VS Code the PowerShell Pro Tools does not fully launch. The workspace button like Package Script as Exe, Show Form Designer, etc.. will appear but upon clicking on any button it will produce a message that "PowerShell Pro Tools is still starting". At the VSCode status bar it says "PowerShell Pro Tools is connecting...". Finally, the navigation bar does not load any items like it is still loading.

To Reproduce Steps to reproduce the behavior: Launch VSCode normally and wait for extension to load like normal.

Expected behavior To fully launch to allow full access to all features using version 2024

Screenshots image

Version

Tool (Visual Studio, VS Code, PSScriptPad, PS Module): 1.90.2 Version Number: v2024.3.1 Operating System: Windows 11 23H2

Additional context On the latest version, before I would be able to disable and enable the extension a couple of times and then it would fully launch. Currently I am not having any luck with doing this method.

I have noticed that if I downgrade version to 2023.12.2 or earlier PowerShell Pro Tools will load after restart of the extension fully. Status bar shows PowerShell Pro Tools is connected. If I upgrade back to any 2024 version then the extension will not load.

Logs

Please upload a log. Logs are found in $Env:AppData\PowerShellProTools\ by default. There is no logs in this location. Only have a license file. I have checked VSCode Output but there is no output for v2024. When on v2023 there is output from VSCode Output. Any other locations to look for logs, please provide.

MikeShepard commented 3 months ago

Same issue, also no logs in that location.

Omzig commented 3 months ago

vscode: OUTPUT: PowerShell Pro Tools

[7/5/2024 9:46:18 AM] Opening a runspace.
[7/5/2024 9:46:18 AM] Loading PowerShell Pro Tools module
[7/5/2024 9:46:18 AM] Executing command: Import-Module 'C:\Users\jxsupport\.vscode\extensions\ironmansoftware.powershellprotools-2024.7.0\Modules\PowerShellProTools.VSCode\PowerShellProTools.VSCode.psd1'
[7/5/2024 9:46:18 AM] Executing command: $Env:PSModulePath += ';C:\Users\jxsupport\.vscode\extensions\ironmansoftware.powershellprotools-2024.7.0\Modules\PowerShellProTools.VSCode\..'
[7/5/2024 9:46:18 AM] Executing command: [PowerShellProTools.IntelliSenseManager]::Isv3()
[7/5/2024 9:46:19 AM] Configuring runspace scheduler.
[7/5/2024 9:46:19 AM] Executing command: 
                Get-Runspace | ForEach-Object {
                    $h = $_.GetType().GetProperty('Host', [System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic).GetValue($_)
                    if ($h.Name -eq 'Visual Studio Code Host') 
                    {
                        $_.Id
                    }
                }

[7/5/2024 9:46:19 AM] Found VS Code runspace: 4
[7/5/2024 9:46:19 AM] Executing command: [PowerShellProTools.IntelliSenseManager]::InitV3(4)
[7/5/2024 9:46:20 AM] Scheduling command for main runspace: Import-Module 'C:\Users\jxsupport\.vscode\extensions\ironmansoftware.powershellprotools-2024.7.0\Modules\PowerShellProTools.VSCode\PowerShellProTools.VSCode.psd1' -Scope Global
Connected to PowerShell process.
Started PowerShell Pro Tools process.

Missing Logs

no logs found in $Env:AppData\PowerShell Pro Tools\

adamdriscoll commented 3 months ago

I just tried on a VM. It connects but the tree view isn't loading anything and refactoring doesn't work.

image

Some features, like the form designer, work. Look into it.

EDIT: Annnnddd I can no longer reproduce on the VM.

adamdriscoll commented 3 months ago

Can folks provide a little more detail?

Omzig commented 3 months ago

Server:

Server:

Workstation:

Omzig commented 3 months ago

I just tried on a VM. It connects but the tree view isn't loading anything and refactoring doesn't work.

image

Some features, like the form designer, work. Look into it.

EDIT: Annnnddd I can no longer reproduce on the VM.

the tree on the left sometimes loads from a fresh install, and as long as you do not restart vscode, you can use the stuff on the left

adamdriscoll commented 3 months ago

I've added more logging around the startup process and added a setting to prevent the terminal from clearing so any errors will be visible.

https://github.com/ironmansoftware/powershell-pro-tools/pull/55

I still can't reproduce this on the 3 machines I tried. Some builds are kicking off for the PR and you could try the VSIX to see if it provides any more information.

MikeShepard commented 3 months ago

FWIW, occasionally the AST pane will load and function while the others are all spinning.

adamdriscoll commented 3 months ago

It's certainly partially loading if any of those function. Still trying to nail down why most features would be stuck.

The AST doesn't used the same Runspace as the PowerShell extension so might be a hint into the issue.

adamdriscoll commented 3 months ago

I've released v2024.7.1 to try to diagnosis this. The Output panel logs should contain a lot more information about the startup process. There is also the poshProTools.clearScreenAfterLoad setting that can be used to disable the Clear-Host that usually happens after the module loads to see if there are any errors.

tarzanboy13 commented 3 months ago

Same issue, Powershell Pro Tools is still connecting, nothing is loaded, everything is up to date

adamdriscoll commented 3 months ago

@tarzanboy13 Do you have anything in the logs? This release did not actually change the startup process but just added some more logging to help diagnosis. Logs are in Output \ PowerShell Pro Tools pane. You should also try setting the poshProTools.clearScreenAfterLoad setting to false.

adamdriscoll commented 3 months ago

TLDR: I was able to reproduce this on another machine and think I have found the behavior that is causing it. You can try this VSIX here: https://github.com/ironmansoftware/powershell-pro-tools/actions/runs/9826757126

The issue seems to be that some features were attempting to access the PoshTools server before it was started.

First, refactoring feature was attempting to send commands to the server while it was starting due to an invalid check on whether the server was started. If you have a PS1 file open and are moving the cursor around the document, it will send a command to get valid refactors over and over again which cause it to attempt to reconnect the server over and over again while it is already trying to start. It somehow gets in a state where it never connects.

Second, the tree view was trying to load before it was connected. While it wasn't sending commands, it would just give up and that's why they would spin forever.

I've fixed the refactor and tree view issues and now I can no longer reproduce on my other machine that was previously exhibiting this behavior.

EDIT: I've been able to reproduce this on at least 4 machines and verify the fix. I'll get a release out and if others are still having problems, we can continue to investigate.

tarzanboy13 commented 3 months ago

I tried new version, for me not working, I have no license as its not needed in vscode.

image

adamdriscoll commented 3 months ago

@tarzanboy13 - Can you go to the PowerShell terminal and type $error? I'm wondering if there was an error as it was trying to import the module.

tarzanboy13 commented 3 months ago

Sorry, this could be correct "powershell terminal" but i used powershell 5.1

$error value

logggg

MikeShepard commented 2 months ago

2024.7.2 shows "there is no data provider that can provide view data" in all panes.

Output for PowerShell Pro Tools shows ths: Starting PowerShell Pro Tools... Finishing extension activation. Connecting to PowerShell Editor Services. Importing module in PowerShell and starting server. Connecting named pipe to PoshTools server. Invoke method: Connect Error sending data on named pipe. Error: connect ENOENT \.\pipe\vbjqcithapwk Already trying to reconnect.

adamdriscoll commented 2 months ago

@MikeShepard Thanks. That's the same startup log that @tarzanboy13 is seeing. The Already trying to reconnect looks to be invalid as it's actually preventing it from retrying. I opened a PR for that. https://github.com/ironmansoftware/powershell-pro-tools/pull/58

That said, I'm not sure why I don't see this either. Do you have errors like @tarzanboy13 does in your PS Extension terminal?

MikeShepard commented 2 months ago

@adamdriscoll - I don't see any errors in the extension terminal. FWIW, this is my home machine rather than work, so no agents/security software to worry about.

adamdriscoll commented 2 months ago

Certainly seems like some sort of timing issue or something. Will continue to test more environments and hope we can continue to gather some info from other folks as well.

MikeShepard commented 2 months ago

I'm getting some to load and some not loading.

In one that doesn't load I see this in the Powershell Pro Tools output window:

Connecting named pipe to PoshTools server. Invoke method: Connect Error sending data on named pipe. Error: connect ENOENT \.\pipe\oelrppegkclb Already trying to reconnect.

In the extension host output window I see this:

2024-07-08 08:51:23.110 [error] Error: connect ENOENT \.\pipe\oelrppegkclb_log at PipeConnectWrap.afterConnect [as oncomplete] (node:net:1595:16)

adamdriscoll commented 2 months ago

I guess that's progress. If you want to try the build with the retry\reconnect fixed, it may improve the situation with the ones not loading: https://github.com/ironmansoftware/powershell-pro-tools/actions/runs/9829865936

Currently, imports the module in PS, waits 1 second and attempts to connect, does not retry and hangs. With the retry fixed, it should attempt to connect again for up to 5 seconds.

MikeShepard commented 2 months ago

It started and connected with all 3 projects I tried:

  1. A small local project (dozens of ps scripts)
  2. A large local project (hundreds of ps scripts)
  3. A large project on a UNC (hundreds of ps scripts)

It did take a bit (~30 seconds) for all of them to load fully, but I think that's to be expected.

adamdriscoll commented 2 months ago

Great news! I'll get a release out.

As for the startup time, that isn't too surprising. Loading the module pane can slow down startup since it takes a while to retrieve all that info.

tarzanboy13 commented 2 months ago

I have this output

image

dragonwarrior00 commented 2 months ago

Great news! I'll get a release out.

As for the startup time, that isn't too surprising. Loading the module pane can slow down startup since it takes a while to retrieve all that info.

@adamdriscoll thank you for the help on this even though I wasn't able to provide much info besides the original post. I was able to get around finally and updated PowerShell Pro Tools extension to the latest version on the vs code marketplace and for me it is working with no issues. Status bar is showing connected. Features are working properly. This is resolved for me.

I see there is some conversations continuing still so I will not set it to close just yet.

tarzanboy13 commented 2 months ago

Ok, for me its working now but i had to open vscode without my big workspace (i opened txt file) and it worked and next time i opened that big workspace with many .ps files and worked and sometimes not. So idk what to do with that sporadical failing on my big WS. It will lost communication during script execution.

adamdriscoll commented 2 months ago

Do you happen to have this setting enabled?

image

Omzig commented 2 months ago

After upgrade:

[8:12:54.631] Starting PowerShell Pro Tools...
[8:12:58.3] Finishing extension activation.
[8:12:58.4] Connecting to PowerShell Editor Services.
[8:12:58.5] Importing module in PowerShell and starting server.
[8:12:59.13] Connecting named pipe to PoshTools server.
[8:12:59.31] Opening a runspace.
[8:12:59.52] Loading PowerShell Pro Tools module
[8:12:59.52] Executing command: Import-Module 'C:\Users\matt_m\.vscode\extensions\ironmansoftware.powershellprotools-2024.7.3\Modules\PowerShellProTools.VSCode\PowerShellProTools.VSCode.psd1'
[8:12:59.102] Executing command: $Env:PSModulePath += ';C:\Users\matt_m\.vscode\extensions\ironmansoftware.powershellprotools-2024.7.3\Modules\PowerShellProTools.VSCode\..'
[8:12:59.113] Executing command: [PowerShellProTools.IntelliSenseManager]::Isv3()
[8:12:59.118] Configuring runspace scheduler.
[8:12:59.119] Executing command: 
                Get-Runspace | ForEach-Object {
                    $h = $_.GetType().GetProperty('Host', [System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic).GetValue($_)
                    if ($h.Name -eq 'Visual Studio Code Host') 
                    {
                        $_.Id
                    }
                }

[8:12:59.177] Found VS Code runspace: 4
[8:12:59.178] Executing command: [PowerShellProTools.IntelliSenseManager]::InitV3(4)
[8:12:59.198] Scheduling command for main runspace: Import-Module 'C:\Users\matt_m\.vscode\extensions\ironmansoftware.powershellprotools-2024.7.3\Modules\PowerShellProTools.VSCode\PowerShellProTools.VSCode.psd1' -Scope Global
[8:12:59.505] Connected to PowerShell process.
[8:12:59.505] Creating tree views.
[8:12:59.507] Starting code analysis.
[8:12:59.507] Started PowerShell Pro Tools process.
[8:12:59.514] Executing command: Get-PSHostProcessInfo
[8:12:59.532] Executing command: Get-Module -ListAvailable
[8:13:2.441] Scheduling command for main runspace: Get-PSProvider | Select-Object -ExpandProperty Name
[8:13:2.643] Scheduling command for main runspace: Get-Job | ForEach-Object { [PowerShellToolsPro.Cmdlets.VSCode.PSJob]$_ } | ConvertTo-Json -WarningAction SilentlyContinue
[8:13:2.961] Executing command: [PowerShellToolsPro.Cmdlets.VSCode.PSAssembly]::GetAssemblies()
[8:13:3.17] Scheduling command for main runspace: [PowerShellToolsPro.VSCode.TreeViewService]::Instance.GetTreeViews() | ConvertTo-Json -WarningAction SilentlyContinue
[8:13:3.275] Scheduling command for main runspace: Get-Content (Get-PSReadLineOption).HistorySavePath | Select-Object -First 25
[8:13:3.599] Scheduling command for main runspace: Get-PSSession | ForEach-Object { [PowerShellToolsPro.Cmdlets.VSCode.Session]$_ } | ConvertTo-Json -WarningAction SilentlyContinue
[8:13:3.916] Scheduling command for main runspace: Get-Variable | Out-PoshToolsVariable -PassThru -ExcludeAutomatic $False | ConvertTo-Json -Depth 1 -WarningAction SilentlyContinue

image

After vscode restart

image

tarzanboy13 commented 2 months ago

Same for me. I am glad that i am not alone.

adamdriscoll commented 2 months ago

Ok. The temporary terminal is currently not supported. PoshTools really doesn't like when the PowerShell Extension terminal process goes away and comes back all the time. We'll have to put some more robust reconnection logic in place to support that.

That said, we should have a clear error message when this is happening in the meantime because it's too hard to figure out what's going on.

EDIT: Another thing we may be able to do now that PoshTools is open source is put in a PR to the PowerShell Extension to have some way of it loading this extension if it's installed. This would effectively remove the need to try to connect from PoshTools to PSES because it would just do the loading for us.

Omzig commented 2 months ago

i created a new vscode profile, reduced my extensions down to 2, and nothing:

image

funny thing, it works in vscode insiders

image

EDIT:

adamdriscoll commented 2 months ago

Ok. Weird. Glad it's working for the most part. We have an issue for tracking the temporary console issue: #34

I think this starting issue is mostly solved so I might just move discussion on the temporary console issue over to that other one and close this. I'll leave this open for a day or so and see if we get some more feedback.