ember-inspector
ember-inspector copied to clipboard
Show pending timers
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.
@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
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.
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?
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 I’m not sure if that’s public API. I’d have to check.
It looks like the TestDebugInfo
class is public in @ember/test-helpers
. You can use that in conjunction with getSettledState
to output this info.