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

Provide more context on infinite recursion in jest.runAllTimers #2893

Closed
ForbesLindesay opened this issue Feb 15, 2017 · 8 comments
Closed

Comments

@ForbesLindesay
Copy link
Contributor

Do you want to request a feature or report a bug?

Feature

What is the current behavior?

If you have an infinite loop of timers and run jest.runAllTimers(), you get the following error:

Ran 100000 timers, and there are still more! Assuming we've hit an infinite recursion and bailing out...

This doesn't really give me any context as to where these timers are. It's fine if the mistake was running jest.runAllTimers() but not if the mistake was having an infinite loop of timers.

What is the expected behavior?

What I would like to see is an error message that looks like the following:

Ran 100000 timers, and there are still more! Assuming we've hit an infinite recursion and bailing out.  The following timers are still pending:

setTimeout
  at someFn (some-file.js:15)
  at someOtherFn (some-other-file.js:17)

setImmediate
  at someFn (some-file.js:16)

i.e. for each pending timer, show what created the timer, and the stack trace at the time the tiemrs were created. This shouldn't affect existing performance too badly because the stack traces would only need to be gathered on the final run whenw e know we're about to report the infinite loop. Because we've already run it 1000 times, any legitimate timers should also already have finished running, which is convenient.

@thymikee
Copy link
Collaborator

I like the idea. Would you be willing to send a PR with the implementation?

@gagyibenedek
Copy link

I am willing to look into it, if this is still relevant. Is it? :)

@thymikee
Copy link
Collaborator

Yup, up for grabs!

@SimenB
Copy link
Member

SimenB commented Mar 10, 2018

It would make more sense to provide this to Lolex as we will (at least most likely) migrate to it (see #5171). If you really want to, go ahead of course, it'll be useful either way :)

@SimenB
Copy link
Member

SimenB commented Feb 5, 2019

I've opened up sinonjs/fake-timers#230

@github-actions
Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Feb 26, 2022
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants
@ForbesLindesay @SimenB @gagyibenedek @thymikee and others