vscode-powershell
vscode-powershell copied to clipboard
Debugger hangs in finally block after CTRL+C
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
Debugger and terminal hangs while debugging script in finally {} block after CTRL+C was pressed.
PowerShell Version
Name Value
---- -----
PSVersion 7.6.0-preview.3
PSEdition Core
GitCommitId 7.6.0-preview.3-29-g14f80030cc1dd1054f447b6a7c4b859285d5bc22
OS Microsoft Windows 10.0.26100
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0, 5.0, 5.1, 6.0, 7.0}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Name : Visual Studio Code Host
Version : 2025.1.0
InstanceId : 9398e63a-02c1-4dec-a50c-2c5056df2b1f
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.98.1
2fc07b811f760549dab9be9d2bedd06c51dfcb9a
x64
Extension Version
[email protected]
[email protected]
[email protected]
Steps to Reproduce
- Set breakpoint at
$counterin thefinally {}block - Start debugging
- Press
CTRL+C
try {
$counter = 0
while ($true) {
$counter++
Write-Host "Counter: $counter"
Start-Sleep -Seconds 1
}
} finally {
$counter
}
Visuals
Logs
PowerShell Trace LSP.log PowerShell.log StartEditorServices-27172.log
@kborowinski thanks! I can reproduce this on 7.5, and wait-debugger works fine in a console so it's not a PS issue nor a preview issue.
Also FYI your logs were ran at info debug level so there's not a lot there, be sure to switch it to debug or trace in the future.
@JustinGrote I did have the debug set to trace. I've run the script again but the logs don't look much different:
StartEditorServices-21352.log PowerShell Trace LSP.log PowerShell.log
Is it another bug?
The troubleshooting docs state that after enabling "powershell.trace.server":"verbose" I should select "PowerShell Editor Services Client" in the output pane, but there is only "PowerShell: Trace LSP" log and it contains [info] only:
And trace is sent to the terminal window instead:
There is full trace:
DEBUG: [Trace] Logging started
DEBUG: [Trace] Beginning EndProcessing block
DEBUG: Removing PSReadLine
DEBUG: [Trace] Creating host configuration
DEBUG: [Trace] Determining REPL kind
DEBUG: [Trace] REPL configured as PSReadLine
DEBUG: [Trace] Configuring LSP transport
DEBUG: [Trace] Configuring debug transport
DEBUG: [Trace] Session file writer created
DEBUG: Adding AssemblyResolve event handler for new AssemblyLoadContext dependency loading
DEBUG: Loading EditorServices
DEBUG: [Trace] PID: 21352
DEBUG:
== Build Details ==
- Editor Services version: 4.2.0
- Build origin: Release
- Build commit: f1c2044ab2c38dd1fda8335a8723c72105703791
- Build time: 2025-01-16 00:00:00
DEBUG:
== Host Startup Configuration Details ==
- Host name: Visual Studio Code Host
- Host version: 2025.1.0
- Host profile ID: Microsoft.VSCode
- PowerShell host type: System.Management.Automation.Internal.Host.InternalHost
- REPL setting: PSReadLine
- Session details path: c:\Users\Bukem\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\sessions\PSES-VSCode-17800-900811.json
- Bundled modules path: c:\Users\Bukem\.vscode\extensions\ms-vscode.powershell-2025.1.0\modules
- Additional modules: <null>
- Feature flags: PSReadLine
- Log path: c:\Users\Bukem\AppData\Roaming\Code\logs\20250312T074113\window1\exthost\ms-vscode.powershell
- Minimum log level: Trace
- Profile paths:
+ AllUsersAllHosts: C:\Program Files\PowerShell\Nightly\profile.ps1
+ AllUsersCurrentHost: C:\Program Files\PowerShell\Nightly\Microsoft.VSCode_profile.ps1
+ CurrentUserAllHosts: D:\Users\Bukem\Documents\PowerShell\profile.ps1
+ CurrentUserCurrentHost: D:\Users\Bukem\Documents\PowerShell\Microsoft.VSCode_profile.ps1
DEBUG: [Trace] Loaded into load context "Default" System.Runtime.Loader.DefaultAssemblyLoadContext #0: Microsoft.PowerShell.Commands.Diagnostics, Version=7.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
DEBUG: [Trace] Loaded into load context "Default" System.Runtime.Loader.DefaultAssemblyLoadContext #0: System.Diagnostics.PerformanceCounter, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
DEBUG: [Trace] Loaded into load context "Default" System.Runtime.Loader.DefaultAssemblyLoadContext #0: Microsoft.PowerShell.Commands.Utility, Version=7.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
DEBUG: [Trace] Loaded into load context "Default" System.Runtime.Loader.DefaultAssemblyLoadContext #0: Microsoft.PowerShell.MarkdownRender, Version=7.2.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
DEBUG: [Trace] Loaded into load context "Default" System.Runtime.Loader.DefaultAssemblyLoadContext #0: System.Text.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
DEBUG: [Trace] Loaded into load context "Default" System.Runtime.Loader.DefaultAssemblyLoadContext #0: System.Net.Http, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
DEBUG: [Trace] Loaded into load context "Default" System.Runtime.Loader.DefaultAssemblyLoadContext #0: Microsoft.PowerShell.Commands.Management, Version=7.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
DEBUG: [Trace] Loaded into load context "Default" System.Runtime.Loader.DefaultAssemblyLoadContext #0: Microsoft.PowerShell.Security, Version=7.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
DEBUG: [Trace] Loaded into load context "Default" System.Runtime.Loader.DefaultAssemblyLoadContext #0: Microsoft.WSMan.Management, Version=7.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
DEBUG: [Trace] Loaded into load context "Default" System.Runtime.Loader.DefaultAssemblyLoadContext #0: Microsoft.WSMan.Runtime, Version=7.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
DEBUG:
== Console Details ==
- Console input encoding: OEM United States
- Console output encoding: OEM United States
- PowerShell output encoding: Unicode (UTF-8)
DEBUG:
== Environment Details ==
- OS description: Microsoft Windows 10.0.26100
- OS architecture: X64
- Process bitness: 64
DEBUG: [Trace]
== PowerShell Details ==
- PowerShell version: 7.6.0
- Language mode: FullLanguage
DEBUG: [Trace] Updated PSModulePath to: 'D:\Users\Bukem\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\powershell\nightly\Modules;C:\ProgramData\scoop\modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules;c:\Users\Bukem\.vscode\extensions\ms-vscode.powershell-2025.1.0\modules'
DEBUG: Validating configuration
VERBOSE: Loading PowerShell Editor Services Assemblies
DEBUG: [Trace] Assembly resolve event fired for Microsoft.PowerShell.EditorServices, Version=4.2.0.0, Culture=neutral, PublicKeyToken=null
DEBUG: Loading PSES DLL using new assembly load context
DEBUG: [Trace] Loaded into load context "PsesLoadContext" Microsoft.PowerShell.EditorServices.Hosting.PsesLoadContext #1: Microsoft.PowerShell.EditorServices, Version=4.2.0.0, Culture=neutral, PublicKeyToken=null
DEBUG: [Trace] Loaded into load context "Default" System.Runtime.Loader.DefaultAssemblyLoadContext #0: System.Reflection.Metadata, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
DEBUG: [Trace] Loaded into load context "Default" System.Runtime.Loader.DefaultAssemblyLoadContext #0: System.IO.MemoryMappedFiles, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
DEBUG: [Trace] Loaded into load context "Default" System.Runtime.Loader.DefaultAssemblyLoadContext #0: System.Collections.Immutable, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Services.Hosting.PsesLoadContext #1: Microsoft.Extensions.Logging.Abstractions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
DEBUG: Creating/running editor services
DEBUG: Creating startup info object
VERBOSE: PSES Startup Completed. Starting Language Server.
VERBOSE: Please check the LSP log file in your client for further messages. In VSCode, this is the 'PowerShell' output pane
Last line in the trace mentions to check the PowerShell output pane but there is not much either:
2025-03-12 07:41:14.936 [info] Visual Studio Code: v1.98.1 64-bit on Windows 64-bit
2025-03-12 07:41:14.936 [info] PowerShell Extension: v2025.1.0
2025-03-12 07:41:14.995 [info] Starting 'PowerShell Core Nightly (x64)' at: C:\Program Files\PowerShell\Nightly\pwsh.exe
2025-03-12 07:41:15.189 [info] PowerShell process started with PID: 21352
2025-03-12 07:41:18.315 [info] [PSES] Microsoft.PowerShell.EditorServices.Logging.HostLoggerAdapter: Loading PowerShell Editor Services Assemblies |
2025-03-12 07:41:18.327 [info] [PSES] Microsoft.PowerShell.EditorServices.Logging.HostLoggerAdapter: Starting PowerShell Editor Services |
2025-03-12 07:41:18.377 [info] [PSES] Microsoft.PowerShell.EditorServices.Logging.HostLoggerAdapter: PSES Startup Completed. Starting Language Server. |
2025-03-12 07:41:18.387 [info] [PSES] Microsoft.PowerShell.EditorServices.Logging.HostLoggerAdapter: Please check the LSP log file in your client for further messages. In VSCode, this is the 'PowerShell' output pane |
2025-03-12 07:41:18.443 [info] [PSES] Microsoft.PowerShell.EditorServices.Services.PowerShell.Console.ReadLineProvider: ReadLine overridden with 'Microsoft.PowerShell.EditorServices.Services.PowerShell.Console.PsrlReadLine' |
2025-03-12 07:41:18.623 [info] Started PowerShell v7.6.0-preview.3.
2025-03-12 07:41:19.438 [info] [PSES] Microsoft.PowerShell.EditorServices.Services.AnalysisService: Found PSSA settings file at 'd:\Users\Bukem\Documents\PowerShell\PSScriptAnalyzerSettings.psd1' |
2025-03-12 07:41:19.439 [info] [PSES] Microsoft.PowerShell.EditorServices.Services.AnalysisService: Configuring PSScriptAnalyzer with rules at 'd:\Users\Bukem\Documents\PowerShell\PSScriptAnalyzerSettings.psd1' |