ember-inspector icon indicating copy to clipboard operation
ember-inspector copied to clipboard

Show pending timers

Open BryanCrotaz opened this issue 4 years ago • 6 comments

Problem I had a test that was hanging on await visit.... I could see in the inspector any pending promises. But I had a backend watchdog service that had a task which looped around ember-concurrency's timeout function. This wraps a run.later which was always present, so hanging the test. Ember Inspector didn't help me to find the fault in my code.

Solution Show pending run.later timers in a tab, similar to the promises tab. Allow tracing of the call that set them up.

BryanCrotaz avatar May 15 '20 03:05 BryanCrotaz

@ember/test-helpers exposes an API that we can leverage for this (or that you can use yourself while debugging): getSettledState.

Docs are here: https://github.com/emberjs/ember-test-helpers/blob/master/API.md#getsettledstate

rwjblue avatar May 16 '20 19:05 rwjblue

Sort of. HasPendingTimers was true, but that didn’t help me find which timer was the culprit. Listing the active timers and seeing the call stack for their creation would have made it easy to debug.

BryanCrotaz avatar May 16 '20 21:05 BryanCrotaz

That information is available within the debugInfo that is included in getSettledState. In fact we actually have a really nice bit of console output, but I don’t know if we expose a way to emit it to the console without timing out the test.

@scalvert - do you happen to recall?

rwjblue avatar May 17 '20 02:05 rwjblue

Either way, this is a good feature for the inspector. I’m just explaining that we don’t need to roll our own, we should leverage the shared infra provided by @ember/test-helpers.

rwjblue avatar May 17 '20 02:05 rwjblue

@rwjblue I’m not sure if that’s public API. I’d have to check.

scalvert avatar May 17 '20 02:05 scalvert

It looks like the TestDebugInfo class is public in @ember/test-helpers. You can use that in conjunction with getSettledState to output this info.

scalvert avatar May 17 '20 02:05 scalvert