While attempting to debug VS Code using the powershell console, the console itself will crash many, many times per day.
The behaviour is always the same, but I can't determine why it happens or see any pattern. When it does happen, it's always when you first start debugging, console just sits there as if frozen.
After a few moments, VS will alert me of an issue with the window, ask me to re-open or wait. Waiting doesn't seem to be helpful (though I've not waited for more than 5 minutes). Re-opening the window will basically restart VS Code and I can typically proceed from there.
I can mitigate this, somewhat, if I "trash" all console instances before I start (i.e. hit the little garbage can on the bottom of the console essentially restarting it), though that doesn't always work either.
VS Version:

Extensions:

Powershell Version:

Logs:
vscode-powershell.log
EditorServices.log
DebugSession-1.log
In this case, I consistently see this error across multiple sessions:
2019-07-29 16:53:25.033 [ERROR] tid:15 in 'ExecuteCommand' C:\PowerShellEditorServices\src\PowerShellEditorServices\Session\PowerShellContext.cs: line 565
Execution of the following command(s) completed with errors:
c:\Work\devops\powershell\test.ps1
Out-Default
There are days when my extension can crash 30+ times which is challenging to say the least.
I've completely uninstalled / reinstalled the extension, VS Code etc. but the results remain the same.
One thing that may or may not be worth noting, in that script (and all my scripts basically) I reference multiple powershell classes as well, that are being imported like this:
using module .\modules\EnvironmentData.psm1
using module .\modules\Tenant.psm1
using module .\modules\ADManager.psm1
using module .\modules\AzureFunction.psm1
Thanks!
Here are my user settings in case these are helpful:
{
"git.autofetch": true,
"git.confirmSync": false,
"window.menuBarVisibility": "default",
"editor.minimap.enabled": false,
"powershell.developer.editorServicesWaitForDebugger": true,
"window.zoomLevel": 0,
"terminal.integrated.rendererType": "dom",
"workbench.colorTheme": "One Monokai",
"powershell.codeFormatting.useCorrectCasing": true,
"workbench.iconTheme": "vscode-icons",
"powershell.debugging.createTemporaryIntegratedConsole": true,
"csv-preview.resizeColumns": "all"
}
@carsontwilson thanks for reporting this, if you do notice a pattern please let us know..more examples of logs from the crashes you are experiencing would also be helpful in determining the cause...thanks!
The logs don't seem to show much, but I've included a zip file with all logging information - I just had two such crashes in a row. Many of the log files are 0kb with no data, but there are a couple with sparse info.
Let me know if I can do more or if there's more logging elsewhere I can include (this is coming from: C:\Users\CarsonWilson\AppData\Roaming\Code\logs)
Edit: Ugh my bad I was at normal logging, I've changed to verbose - let's see what it turns up! :)
@carsontwilson thanks for the additional information, please update with the diagnostic logging if you continue to see these crashes --instructions for how to do that are here
In VSCode you can open and read the logs directly from the Command Palette (Ctrl+Shift+P) with PowerShell: Open PowerShell Extension Logs Folder.
Ok I have additional logging - I do have it set to verbose, but it doesn't seem to have added much in the logging. The crash occurred right about 9:20a...
2-PowerShell Extension Logs.log
exthost.log
main.log
4-PowerShell Editor Services.log
2-PowerShell Extension Logs.log
@carsontwilson thanks for providing these logs..every bit of information helps! Some of these logs files arent ones we typically see though...where are you grabbing these files from?
Hey there - I'm getting the logs from this location:
C:\Users\CarsonWilson\AppData\Roaming\Code\logs
Is there somewhere else I should get them from as well / instead of?
@carsontwilson the logs we are looking for should live in:
$HOME/.vscode/extensions/ms-vscode.powershell-2019.5.0/logs/
Thanks!
Ok I've got logs from a crash that happened just a moment ago from that location. My script threw an exception and the powershell shell then terminated. I fixed my code, and started the shell via debug again and that's when it locked.
I can see the exception that my code threw in the logs, but I didn't see anything else that indicated an error. Still, I've attached the logs.
Thanks!
DebugAdapter.log
DebugSession-1.log
DebugSession-2.log
EditorServices.log
vscode-powershell.log
This is a curious exception:
System.Management.Automation.RuntimeException: t is not a valid choice
Are you (or a script you're using) prompting with $Host.UI.PromptForChoice?
Most helpful comment
The logs don't seem to show much, but I've included a zip file with all logging information - I just had two such crashes in a row. Many of the log files are 0kb with no data, but there are a couple with sparse info.
Let me know if I can do more or if there's more logging elsewhere I can include (this is coming from: C:\Users\CarsonWilson\AppData\Roaming\Code\logs)
20190823T093944.zip
Edit: Ugh my bad I was at normal logging, I've changed to verbose - let's see what it turns up! :)