Skip to content

Debugger sometimes get stuck in "running" state even though it's paused #2282

Closed

Description

@DanTup

Moving from dart-lang/sdk#40725.

If you run this:

void main() {
  var steps = 0;
  while (true) {
    steps++; // Breakpoint here
    print('Has run $steps steps');
  }
}

Then keep pressing F5, you'll quickly end up in a state where VS Code thinks the app is running (it has a Pause button) but it is stopped at the breakpoint.

The issue seems to be that we process the response to the resume command sent to the VM after the PauseBreakpoint event, resulting in the UI being left in the "running" state when it's actually paused.

Screenshot 2020-03-02 at 16 26 40

The events in the log are in the correct order (suggesting they came from the VM in the correct order):

Screenshot 2020-03-02 at 16 26 50

Activity

  1. added
    in debuggingRelates to the debug adapter or process of running debug sessions
    on Mar 2, 2020
  2. added this to the v3.9.0 milestone on Mar 2, 2020
  3. DanTup commented on Mar 2, 2020

    @DanTup
    MemberAuthor

    When we get a response to a request, we resolve/request the promise. However the code waiting on it won't be executed until we next field. If the "next message" (the PauseBreakpoint event) is already received before this, then it may be in the queue before this, and it then gets called synchronously.

    Screenshot 2020-03-02 at 16 38 56

    Forcing a yield in the event callback (for ex `setTimeout) may resolve it, though I don't know if it may introduce other subtle timing issues. This also sounds familiar like it's come up before...

  4. DanTup commented on Mar 2, 2020

    @DanTup
    MemberAuthor

    We hit this before here:

    #471 (comment)

    The fix was quite specific to the streamed results from the analysis server though. Until I have a better fix, I'm going to add a setTimeout(0) around the events to and get them back in the correct order.

  5. added a commit that references this issue on Mar 2, 2020
    bd4ee80
  6. DanTup commented on Mar 2, 2020

    @DanTup
    MemberAuthor

    Fix seems to work in my testing, and doesn't seem to have broken anything else.

    @shyndman @jensjoha if nothing breaks on CI, I'll merge this and make a new build that you can use to check it seems fixed for you too.

  7. added a commit that references this issue on Mar 2, 2020
    74e0e90
  8. DanTup commented on Mar 2, 2020

    @DanTup
    MemberAuthor

    There's a dev build at https://github.com/Dart-Code/Dart-Code/releases/tag/v3.9.0-alpha.3 if anyone wants to try it out (you'll automatically be moved back to stable releases when the next version is released).

  9. shyndman commented on Mar 2, 2020

    @shyndman

    Amazing! I'll use it for the day and report back.

  10. shyndman commented on Mar 3, 2020

    @shyndman

    So far so good :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in debuggingRelates to the debug adapter or process of running debug sessionsis bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions