timer IDs aren't spec compliant
Closed this issue · 2 comments
AlexandreBonaventure commented
What is expected ?
According to spec, if I understand correctly, IDs returned by setInterval/setTimeout should be greater than zero. https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers
What actually happens ?
workerTimers.setInterval(cb) // return 0 the first time
This is actually a big discrepancy because (in my knowledge) it is a common practice to clear the interval/timeouts by doing:
function startTimer() {
if (id) clearTimeout(id)
setTimeout(cd, 1000)
}
This snippet would fail with your implementation but works with window.setTimeout
chrisguttandin commented
Hi @AlexandreBonaventure, thanks for making me aware of that discrepancy. The issue should be fixed in version 6.0.2.
AlexandreBonaventure commented
that was quick! thanks