-
Notifications
You must be signed in to change notification settings - Fork 107
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
Scheduling timers during tick
with timeout of 0
forcing timeout of 1
#166
Comments
Web timers delay subsequent nested timer calls. Although the spec uses a different quota:
|
Cool! I'll just remove that test from Jest then, as it tried to assert the wrong behavior. Thanks for the quick response! |
Note that we do have a config.loopLimit which you can use to avoid infinite recursion with timers if you'd like to preserve the bailing test. |
|
@benjamingr a question popped up - that's the HTML spec, is it implemented the same in Node? |
@SimenB yes, pretty much - though if you'd like more "official clarification" of what we can commit to for timers I can bring it up internally in Node. We don't actually have a spec the way web timers do but try to stay compatible. |
Nah, as long as it matches, and it's a goal to match in the future (so it won't drift more or less arbitrarily) that's more than enough for me 🙂 In general I wouldn't mind the node docs explicitly stating at least where their implementation deviates from web specs, but that's not timer specific. |
Well, timers are pretty much the only API node has that looks like a web API and isn't - the other stuff either has different naming and methods (EventTarget vs EventEmitter) or is actually the same (like URL). |
Ah, fair enough! |
See the following code: https://github.com/sinonjs/lolex/blob/63b192998893a3a22203d7b0741864e2fc1b91ce/src/lolex-src.js#L219
Jest has a test that running fake timers bail if the infinitely recurse, it looks like this:
timers.advanceTimersByTime
is implemented usingclock.tick
.However, this doesn't throw anymore, and I think it's because of the code line I linked above.
My question is: is it on purpose that when
parseInt(timer.delay)
is0
(thus falsy) that you should care aboutduringTick
?The text was updated successfully, but these errors were encountered: