Debugger Issues
Prerequisites
- [X] I have written a descriptive issue title.
- [X] I have searched all issues to ensure it has not already been reported.
- [X] I have read the troubleshooting guide.
- [X] I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
Summary
REF: https://github.com/PowerShell/vscode-powershell/issues/3394#issuecomment-904786408
After attempting to resolve my issue with the pre-release version of the extension, the debugger started failing again. Per @rjmholt 's suggestion, I am opening a new issue for tracking.
PowerShell Version
Both PS 5.1 and 7 have issues.
Name Value
---- -----
PSVersion 7.1.0
PSEdition Core
GitCommitId 7.1.0
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Name Value
---- -----
PSVersion 5.1.18362.1474
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.1474
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Visual Studio Code Version
1.59.1
3866c3553be8b268c8a7f8c0482c0c0177aa8bfa
x64
Extension Version
[email protected]
[email protected]
Steps to Reproduce
Scenario 1 (PowerShell 5.1)
- Close all VSCode instances
- Open new instance with no folder opened
- Create a new PowerShell script
- Past in script below (do not save)
function Write-SomeStatus {
# Breakpoint on following line
Write-Host 'Some Status'
}
Write-SomeStatus
- Press F5
Expected: Breakpoint is hit Actual: Breakpoint is skipped and script contents + "Some Status" is written to terminal
Scenario 2 (PowerShell 5.1)
- Save the script from Scenario 1 to C:\temp\DebuggingTest.ps1
- Readd the breakpoint to line 3 (as indicated)
- Press F5
- Debugger starts and attaches correctly
- Press F5 to run to completion
- Run
Write-SomeStatusfrom the terminal directly - Debugger attaches to breakpoint at line 3
- Press F5 to continue and the debugger hangs (screenshot below)
Visuals
Debugger attaches when adding new Write-Host line:

Debugger hangs after calling from terminal directly:

Logs
EditorServices.log StartEditorServices.log vscode-powershell.log
Yeah...this did not quite work. I'll see if I can figure it out but unfortunately I think it's going to be a bit more complicated than just adding that code at the end of ExecuteCommandAsync.
NestedPromptLevel is 1 is probably better anyway.
Basically it's just checking that the current REPL isn't for a debugger stop, a remote runspace, or a nested prompt.
!PromptNest.IsInDebugger is what we were looking for, but even with that, it's not quite working.
Roger that, I'll take a crack at it this weekend and see if it's feasible
I seem to be sending the notification too soon...I'll take a look in the morning. It is stopping the debugger now, just it's doing so immediately after the breakpoint is hit. So it starts and then stops.
Yeah that might not be the best place for the check. It's possible that it's firing right after some of the pre-debugger REPL stuff like setting breakpoints. Right now we'd be setting it once it returns to the "normal" prompt in the stack, but that doesn't necessarily mean that execution is resumed (and ofc very often doesn't mean execution is finished). Maybe the check should be when ReadLine is called? Or in an execution status event handler?
Hey...it's a-working. It just might be a bit fragile (and it needs tests).
@strickdd Can you test out the preview extension that updated yesterday for Scenario 2? I believe I've lit that feature up, but still working on a way to thoroughly cover it in tests.
This change got dropped in the pipeline rewrite, so I am reopening this. The good news is that I also just fixed that!