Scope
This article only applies to PowerShell Pro Tools for VS Code on the Windows operating system.
If you are using PowerShell Pro Tools for VS Code for Mac or Linux then this article does not apply
Problem
The PowerShell Pro Tools extension for VS Code fails to connect after some time. This may result in features being unavailable (i.e. "command not found")
Symptoms
The first symptom will be a status of "PowerShell Pro Tools is connecting..." for more than a couple of seconds.
(figure shows the first symptom - PowerShell Pro Tools for VS Code extension is trying to connect)
Versions 2023.9.0 and below, 2024.2.0 and above
The status will remain at the first symptom.
Versions 2023.12.1, 2023.12.2
After a couple of minutes, the extension will stop trying will present the below status window with a recommendation to check the Output channel.
(figure shows the second symptom on version 2023.12.2)
Version 2023.12.0
Same as 2023.12.1, but the application will also eventually exhaust its available memory and terminate.
Root cause
The issue can occur in the PowerShell Pro Tools VS code extension when a non-existent backup path is defined in the windowState section of the VS Code user cache. See below.
(figure shows an example of a non-existent path defined in the windowState section of the storage.json in the VS Code user cache)
(figure shows the typical location of the storage.json file in the VS Code user cache)
Workarounds
A list of workarounds to choose from is below. Please be sure to close VS Code before proceeding.
Workaround #1 (recommended)
1) Disable persistent sessions in VS Code (shown below). We apologize for this inconvenience. This setting controls whether or not VS Code will not remember the exact state of its child windows when it was closed. This incompatibility between PowerShell Pro Tools for VS Code and the persistent session feature will be fixed in the future.
Workaround #2
1) Edit the storage.json to remove the workSpace section (zero impact, best solution) (see below)
(figure demonstrates how to edit the storage.json file with NotePad)
Workaround #3
Delete the storage.json file altogether (should be low impact)
Workaround #4 (not recommended)
Remove the %APPDATA%\Code folder altogether. This will effectively reset all of the user settings.
Final Step 🏁
After applying one of the above workarounds, start VS Code and after a few seconds (depending on your computer performance) you should see the extension connect and turn green (see below).
(figure shows the PowerShell Pro Tools extension for VS Code successfully connected)