Skip to content

Add ability to observe active timers and microtask queues  #2152

Description

@mehmetf

[I am filing within the context of widget tests but I believe this is useful in general for debugging Dart code.]

Certain Widget tests use runAsync to run code in real async zone. These tests are often flaky and developers have a hard time understanding why. Most often the culprit is some Timer or Microtask that causes a side-effect that the test depends on. If this task does not run in time, it hangs the test.

When I was debugging an issue like this, I had to instrument ZoneSpecification to figure out what was creating the timers and microtasks. This is advanced debugging for a regular user who often does not understand zones.

The request here is to be able to see active timers and the microtask queue of the current zone when the code is paused at a breakpoint. It would also be helpful to see all Timers and microtasks but this might be more confusing than helpful. When the user taps on a timer it would be useful to see where the timer was originally created and what its current state is.

Activity

  1. Hixie commented on Jul 7, 2020

    @Hixie

    This would be massively helpful.

  2. added this to the Backlog milestone on Jul 7, 2020
  3. devoncarew commented on Jul 7, 2020

    @devoncarew
    Contributor

    This is definitely feasible. One way to visualize this would be to have an artificial 'zone' variable in the variables view. Expanding that could should you interesting information, like timers and such.

    The request here is to be able to see active timers and the microtask queue of the current zone

    Once we have a reference to the zone object, we'd need to have some methods we could call on it (either via some service protocol calls, or via expression evaluation) in order to populate the info in the debugger. cc @bkonyi for how we could populate this info.

    The service protocol does have some existing functionality for seeing pending isolate messages, but I don't believe it's possible to tie that back to more semantic zone info; https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md#stack.

  4. added
    P3issues we think are valid but not important
    on Sep 27, 2024
  5. mx1up commented on Nov 19, 2024

    @mx1up

    does there currently exist any method to inspect the message queue? I read it was previously available in "observatory" which has since been replaced by DevTools?

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

    P3issues we think are valid but not importantdevtools-debugger-screenIssues with the Debugger screeng3

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions