Skip to content
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

Show pending timers #1218

Open
BryanCrotaz opened this issue May 15, 2020 · 6 comments
Open

Show pending timers #1218

BryanCrotaz opened this issue May 15, 2020 · 6 comments

Comments

@BryanCrotaz
Copy link

BryanCrotaz commented May 15, 2020

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.

@rwjblue
Copy link
Member

rwjblue commented May 16, 2020

@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

@BryanCrotaz
Copy link
Author

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.

@rwjblue
Copy link
Member

rwjblue commented May 17, 2020

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
Copy link
Member

rwjblue commented May 17, 2020

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.

@scalvert
Copy link

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

@scalvert
Copy link

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

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

No branches or pull requests

4 participants