Skip to content

VSCode stops processing 'Start Debugging' #2175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
PrzemyslawKlys opened this issue Sep 13, 2019 · 80 comments
Closed

VSCode stops processing 'Start Debugging' #2175

PrzemyslawKlys opened this issue Sep 13, 2019 · 80 comments
Assignees
Labels

Comments

@PrzemyslawKlys
Copy link
Contributor

Issue Description

I am experiencing a problem with... F5 ('Start Debugging') stopping to work very often. Last few weeks it has been stopping all the time. I am not sure if the logs are of any help thou. I have to restart PowerShell session or use F8.

Attached Logs

Follow the instructions in the README about
capturing and sending logs.

1568380290-e5000958-344d-442c-be6c-5a263b8675e61568354258606.zip

Environment Information

Visual Studio Code

Name Version
Operating System Windows_NT x64 10.0.18362
VSCode 1.38.1
PowerShell Extension Version 2019.5.0

PowerShell Information

Name Value
PSVersion 5.1.18362.145
PSEdition Desktop
PSCompatibleVersions 1.0 2.0 3.0 4.0 5.0 5.1.18362.145
BuildVersion 10.0.18362.145
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand)
Extension Author Version
auto-rename-tag formulahendry 0.1.0
beautify HookyQR 1.5.0
bracket-pair-colorizer-2 CoenraadS 0.0.28
code-settings-sync Shan 3.4.2
gitlens eamodio 9.9.3
html-css-class-completion Zignd 1.19.0
live-html-previewer hdg 0.3.0
markdown-all-in-one yzhang 2.4.2
markdown-preview-enhanced shd101wyy 0.4.3
markdown-shortcuts mdickin 0.11.0
material-icon-theme PKief 3.9.0
powershell ms-vscode 2019.5.0
project-manager alefragnani 10.7.0
theme-monokai-pro-vscode monokai 1.1.14
vscode-html-css ecmel 0.2.3
vscode-wakatime WakaTime 2.2.0
xml DotJoshJohnson 2.5.0
@ghost ghost added the Needs: Triage Maintainer attention needed! label Sep 13, 2019
@rjmholt
Copy link
Contributor

rjmholt commented Sep 26, 2019

Thanks for opening an issue @PrzemyslawKlys. Can I ask what you mean by "stopping" here? Would you be able to attach a GIF maybe of the process occurring? Is it a crash, or is debugging just ending unexpectedly? Or is it hanging?

There's a strange sequence I've observed in some logs recently where VSCode sends us a debugger shutdown message. It's likely in response to something we do, but it's a new change in VSCode and we haven't worked out what's going on there yet.

@PrzemyslawKlys
Copy link
Contributor Author

Generally it works in a way where I press F5 wait for script to finish, fix something, run again and again and randomly (sometimes after 2 minutes, sometimes after 2 hours) F5 just stops responding. Nothing is happening when pressed. You have to restart session to continue. But it's not crashed. Just not responding. To me it looks like I pressed F5 and it did register it and started executing in the background but it didn't inform the GUI and at that point The debug session is running on it's own. But that’s just a noob guess.

@rjmholt
Copy link
Contributor

rjmholt commented Sep 27, 2019

To me it looks like I pressed F5 and it did register it and started executing in the background but it didn't inform the GUI and at that point The debug session is running on it's own

Yeah that sounds familiar. Well @TylerLeonhardt's been working hard on some big changes here, so we should have something new to try in the next few weeks hopefully.

@SydneyhSmith SydneyhSmith removed the Needs: Triage Maintainer attention needed! label Sep 30, 2019
@westerdaled
Copy link

I am also getting affected by this issue again; resulting in frequent "nostalgic" use of the ISE 😯

Is there a min version of PowerShell 5 we should be using?
`
ame Value


PSVersion 5.1.18362.145
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.145
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
`

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Oct 8, 2019
@TylerLeonhardt
Copy link
Member

PowerShell 5.1 should work. What version of the .NET Framework do you have installed just so we know?

The next preview extension release will have the refactor that @rjmholt mentioned. I'd love to hear what you folks have to say when that drops.

@TylerLeonhardt TylerLeonhardt removed the Needs: Maintainer Attention Maintainer attention needed! label Oct 8, 2019
@PrzemyslawKlys
Copy link
Contributor Author

I can give it a go, however if it will have problems with PSReadline it's a bit useless.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Oct 8, 2019
@westerdaled
Copy link

PowerShell 5.1 should work. What version of the .NET Framework do you have installed just so we know?

The next preview extension release will have the refactor that @rjmholt mentioned. I'd love to hear what you folks have to say when that drops.

regedit HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\1033 it show for Release key: 528040 which is .NET framework 4.8 ( probably through windows update) . I am happy to test the refactor ( hopefully PSReadline support is stable) . At the end of the day I just want to get to the bottom of the debug "suspended animation" I like others seem to be experiencing

@rjmholt
Copy link
Contributor

rjmholt commented Oct 10, 2019

Ok just took a look through the logs again and it's not clear just yet what the issue is. We're hoping to get the new version of debugging stack out soon as a preview release (it's just waiting on some upstream logging work so we can find bugs better) so when that's out it may well solve this issue

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Oct 10, 2019
@westerdaled
Copy link

westerdaled commented Oct 11, 2019

Yes that will be helpful. Tried to test new ( 3 line ps script) and had to give up debugging it in VScode because of this issue. Odd the issue occurs randomly.

Note sure if this is related but even after closing and restartng VScode, I am seeing this:
Cannon debug PowerShell

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Oct 11, 2019
@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Oct 15, 2019
@PrzemyslawKlys
Copy link
Contributor Author

Just to add a new version, preview one didn't fix the issue. I still press F5 and nothing happens. What's worse is that there's no progress anymore on PowerShell script (as in the bottom information that script is running is not there in preview - or at least it doesn't show very often).

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Nov 4, 2019
@PrzemyslawKlys PrzemyslawKlys changed the title VSCode stopps processing 'Start Debugging' VSCode stops processing 'Start Debugging' Nov 4, 2019
@westerdaled
Copy link

westerdaled commented Nov 4, 2019

@PrzemyslawKlys you prompted me to test out PowerShell Preview 2019.110 and for the first time against a script with a breakpoint actually displays the top "step over / in" tool bar. I haven't seen that in weeks; even with two line scripts! Will still need to do a lot more testing as I am not convinced anything has changed. BTW nothing showing about the script running on footer toolbar in this scenario.
@rjmholt is the purpose of this release to instrument more granular logging within the extension rather than fix the "F5 freezing" issue?

@rjmholt
Copy link
Contributor

rjmholt commented Nov 4, 2019

Purpose of the release is explained here.

@westerdaled are you experiencing the issue you describe here, or is it that you have completions and the integrated console but F5 doesn't work?

I still press F5 and nothing happens.

@PrzemyslawKlys do you mean F5 never works, or that it stops working after some time (as you reported initially).

Can you both please load the preview extension, try F5 and send through the logs?

@PrzemyslawKlys
Copy link
Contributor Author

It works, randomly stops. But it didnt change at all.

@rjmholt
Copy link
Contributor

rjmholt commented Nov 4, 2019

But it didnt change at all

Ok good to know. I think I just managed to reproduce this as well, so we are a step closer fixing it (if I can hit it again).

@rjmholt
Copy link
Contributor

rjmholt commented Nov 4, 2019

Ok, I think my repro of this only happens when I artificially stop PSES in the debugger, get the PS extension to stop debugging, and resume PSES. I'm not sure how this would occur in a normal scenario, but I can't reproduce it without the debugger.

When I did get it into that state, we don't even get to the point of handling the initialize message. So this might be something we need to fix in Omnisharp.

@rjmholt
Copy link
Contributor

rjmholt commented Nov 4, 2019

@westerdaled when you describe something showing the script running in the footer bar (VSCode's status bar) what do you mean?

@corbob
Copy link
Contributor

corbob commented Nov 5, 2019

@rjmholt In stable there's a spinning arrow when a script is running:

image

but preview doesn't show this:

image

Interestingly it doesn't show that in 2019.9.0 either and apparently I never noticed it was missing.

@PrzemyslawKlys
Copy link
Contributor Author

Btw. during debugging if you do some longer running code (press F9 on first Write-Host) and you let it go... it will not show running PowerShell progress anymore. It will silently continue.

function Get-myTest {
    [alias('Get-WinADGPOSysvol')]
    [cmdletBinding()]
    param(
        $Test
    )

    Write-Host $Test
    Start-Sleep -Seconds 15
    Write-Host $Test
}

@PrzemyslawKlys
Copy link
Contributor Author

PrzemyslawKlys commented Jan 12, 2020

When there is hanging session (so F5 stops working) when you press F6 (I did it by accident) you get this:

image

@TylerLeonhardt
Copy link
Member

@PrzemyslawKlys I'm pretty sure this is because the debugger is currently active... it's not clear with your theme and I'm guessing you disable the little pop up that shows up...

Can you try with like the ISE theme or something? There's no way for us to really know when you've "stopped executing" so the experience is that you're dropped into the debugger and are in the debugger until you stop the debugger.

@PrzemyslawKlys
Copy link
Contributor Author

Have you tried my reproduction steps?

@TylerLeonhardt
Copy link
Member

Yep. That's why I ask. I ran through the steps and the reason F5 didn't work was because the debugger was already on.

@PrzemyslawKlys
Copy link
Contributor Author

PrzemyslawKlys commented Jan 15, 2020

Ok, I think we have a misunderstanding here.

  • I use F5 to run script and F5 to continue (as in going to next breakpoint)

I'm basically only using:

  • Continue / Pause F5
  • Step Over F10
  • Step Into F11
  • Step Out Shift+F11
  • Restart Ctrl+Shift+F5
  • Stop Shift+F5

Nothing else.

F5bug1

I understand now what you mean with colors (I always check for the progress bar in my theme - and missing during debugging).

I also look at [DBG] in cmdline to see whether I'm during debugging or not. Not sure why would you get orange color after I press continue on Write-Host and than it waits for a long time until I actually use SHIFT+F5.

@PrzemyslawKlys
Copy link
Contributor Author

If I'm reading new "colors" correctly is that when I press F5 the code enters debug. Then I press F5 it seems like console says "ok we're done), yet the orange color stays on and when I execute something again it's basically Debug within Debug within Debug at some point. So it would seem like Debugger doesn't detach properly when it's done and VScode is lost.

@TylerLeonhardt
Copy link
Member

Yeah this has been the case for the Interactive Session debugging for as long as I've been working on this project and it's not a perfect experience... Let me chat with @rjmholt and @SydneyhSmith about this behavior... but it's not a new problem.

@PrzemyslawKlys
Copy link
Contributor Author

PrzemyslawKlys commented Jan 16, 2020

To be honest I don't really understand why would this behavior be like that. If I run code interactively it never goes out of debugging, yet the [DBG] is gone and the console acts as if it's done. Although the status bar still is orange. My understanding was that it will act like normal. If I press F5 and there are no more breakpoints it should finish up and stop. I have now changed color for my current theme to the orange status bar for debugging just to make sure it's visible what is happening.

Hopefully, this will allow me to have fewer frustrations as I've been restarting PowerShell 50 times a day not knowing what is happening. Not sure if this is the only cause of my problems but this one I was able to pinpoint.

@DarkLite1
Copy link

I have to admit, the only way I debug and/or develop code is interactive. I never launch a script from the terminal. Maybe that's a result from being spoiled by the PowerShell ISE. However, I think many users are developing the same way.

@PrzemyslawKlys
Copy link
Contributor Author

But I believe I have hit these errors also when developing in script pane only. I can't be really sure because I couldn't pinpoint it, but now that I know what to look for it may be a bit easier to spot & recover if possible.

@rjmholt
Copy link
Contributor

rjmholt commented Jan 16, 2020

To step out of my maintainer boots for a moment...

I always use Launch Current File and it behaves the way I expect a debugger would. Interactive Session isn't really my wheelhouse, so I don't know what the expectations are (and in my experience, expectations with a lot of PowerShell IDE features vary).

@PrzemyslawKlys
Copy link
Contributor Author

PrzemyslawKlys commented Jan 16, 2020

My expectations would be:

  1. When I press F5 it executes the file as it does now
  2. If it hits breakpoint debugger is still there
  3. If I continue with F5 and it reaches the end of the file/script it should detach the debugger

There is inconsistency right now:

  1. Orange bar stays on (if you use a proper theme that shows that appropriately).
  2. [DBG] in a console is removed
  3. Progress icon is gone

This makes it hard to understand what's going on.

Why would debugger stay on if the command is finished? It's not like I did enter debugging manually and then run the script and wanted to stay within the debug session.

Hopefully, I am not the only one complaining about this. Maybe I'm just misusing the tool 🤷‍♀️

@rjmholt
Copy link
Contributor

rjmholt commented Jan 16, 2020

Ok @TylerLeonhardt has explained this to me and I'll try my best to explain my understanding of the situation.

It comes down to:

  • VSCode sends no notification when you're not debugging and set breakpoints, instead it sends all set breakpoints when you start debugging
  • When you're in debug mode, it continues to update breakpoints (it sends the full list of breakpoints each time you set or remove a breakpoint)
  • Once you drop out of debug mode, it no longer sends breakpoint updates, even though it shows set breakpoints in the sidebar. Instead it saves them up for when you next launch the debugger.

Users from the ISE expect the following scenario to work:

  • Set breakpoints in my script
  • Launch the debugger
  • Hit the breakpoint
  • Let the script continue to completion
  • Set another breakpoint (or remove breakpoints)
  • Rerun script
  • Hit the new breakpoint (or don't hit removed breakpoint)

But once we drop out of debug mode, we never get an update from VSCode about breakpoints (since we don't control VSCode, that means we're blind to breakpoints set in it). That means any changes you make in breakpoints at that time won't get hit if you run something from the console.

But even though F5 has become synonymous with "Run script", it really means "Run current debug configuration". When VSCode gets told this, it says "But I'm already in debug mode".

See also: #2371, PowerShell/PowerShellEditorServices#1091


In reference to @PrzemyslawKlys's particular issues:

  1. Orange bar stays on (if you use a proper theme that shows that appropriately).

That means VSCode in debug mode and will send updates about breakpoints.

  1. [DBG] in a console is removed

That's because you're not stopped in the debugger. You're in debug mode, but you're not currently in a nested debug prompt. When you see [DBG], debugger console commands like continue or list apply.

  1. Progress icon is gone

This is likely because there's no script executing, the same reason for (2). You're in debug mode, but there's no script running.


Ideally we could progress on this issue by either coming up with a clever workaround to the VSCode problem, or possibly coming up with a configuration where users can pick what behaviour they want. I suspect the two options are:

  1. [Current behaviour] Remain in the debugger after script has finished running, breakpoints set in the VSCode sidebar will be hit when scripts are run from the terminal, breakpoints persist throughout session. This means you get "shadow" breakpoints (ones set in PowerShell that VSCode doesn't know about) and F5 won't rerun a script.
  2. Drop out of the debugger when current debug execution finishes, remove all PSBreakpoints (breakpoints set in VSCode will remain showing). Running scripts at this point will never launch the debugger; that must be done from VSCode. This means that debugging cmdlets like Set-PSBreakpoint and Wait-Debugger won't work.

There's probably a bit of extra engineering we can do here, but I think the rest is best done with configuration so that everyone can have the experience they prefer with whatever compromises that might entail.

@PrzemyslawKlys
Copy link
Contributor Author

Just to be clear - does it cover both scenarios I am using or just one of them?

  1. Running script from script pane
  2. Running script from script pane (to "activate" function) and finally typing the function in the console?

@rjmholt
Copy link
Contributor

rjmholt commented Jan 16, 2020

Running script from script pane

This would work if we deactivate debugging after script completion. Pressing F5 a second time would run the script again.

Running script from script pane (to "activate" function) and finally typing the function in the console?

That won't work if we deactivate debugging after a script completes. The breakpoints set in the function will be washed away.

@SydneyhSmith SydneyhSmith added Issue-Discussion Let's talk about it. and removed Needs: Maintainer Attention Maintainer attention needed! Issue-Bug A bug to squash. labels Jan 16, 2020
@DarkLite1
Copy link

So,after a long read, just for my understanding of the problem I did a small test on the latest vscode-insiders. What I did:

  1. Write a new function in a file that is not found in any module
  2. Press F5 to execute the current script pane or script file
  3. Go to the PSIC terminal and try to use the new function
  4. The function is properly executed and in the session

image

@PrzemyslawKlys does this not cover your case? Maybe I misunderstood and you can write a simple test case.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Jan 17, 2020
@TylerLeonhardt TylerLeonhardt removed the Needs: Maintainer Attention Maintainer attention needed! label Jan 17, 2020
@SydneyhSmith SydneyhSmith added Needs: Maintainer Attention Maintainer attention needed! and removed Needs: Maintainer Attention Maintainer attention needed! labels Jan 21, 2020
@flexiblefactory
Copy link

flexiblefactory commented Oct 18, 2022

There is definitely a problem with the debugger in latest VSCode (1.72.0). When running multiple processes in the debugger (in my case node processes), I often see both processes appear to stop (hang, not terminate) - for no reason. I then am unable to start a new debug session, nor terminate the existing ones, and the only solution is to close the Code window.

@ghost
Copy link

ghost commented Oct 18, 2022

Thank you for your comment, but please note that this issue has been closed for over a week. For better visibility, consider opening a new issue with a link to this instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants