Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

$interval ngMock has infinite loop when delay argument is equivalent to zero #15952

Closed
1 of 3 tasks
luciomartinez opened this issue May 2, 2017 · 0 comments
Closed
1 of 3 tasks

Comments

@luciomartinez
Copy link
Contributor

I'm submitting a ...

  • bug report
  • feature request
  • other (Please do not submit support requests here (see above))

Current behavior:

When writing a spec if an interval is set with a delay argument equivalent to zero, then using the flush method will generate an infinite loop.

Expected behavior:

When running setInterval(..., 0); in the browser it is executed almost every tick, for mock the same behavior is expected.

Minimal reproduction of the problem with instructions:

https://plnkr.co/edit/uzZeMC8ruoEOT1l2MijI?p=preview

  1. Open the app.spec.js file
  2. Uncomment the line with the flush method

Result: the browser's tab will crush due infinite loop.

Angular version: 1.6.4

Browser: all

Anything else:

PhantomJS 2.1.1 (Windows 8 0.0.0) ERROR
  Disconnected, because no message in 10000 ms.
@gkalpak gkalpak added this to the Backlog milestone May 2, 2017
@gkalpak gkalpak closed this as completed in 32f4645 Jun 6, 2017
gkalpak pushed a commit that referenced this issue Jun 6, 2017
Previously, trying to test code thaat contained zero-delay intervals (e.g.
`$interval(fn, 0)` or `$interval(fn)`) would result in an infinite loop.
This commit avoids the infinite loop, by treating zero-delay intervals as one
second intervals (except for the initial trigger, where they can also be
executed with `$interval.flush(0)`).

Fixes #15952

Closes #15953
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants