0

I've done a fair bit of reading around Javascript's setTimeout and setInterval methods (here and here) and know that interval events can get dropped if more than one gets queued.

However, I would like to know if there are situations where even a timer event set by setTimeout would get dropped. I can't find any documentation on this but based on user feedback it does appear that occasionally a timer event doesn't execute at all, it's not just delayed, it never executes.

I suppose it could just be indefinitely delayed but the web page remains responsive so I doubt that's the case.

It's been impossible to consistently replicate but we've had enough reports to be certain that it's actually happening.

Any info on this would be great.

Many thanks.

pn206
  • 43
  • 4
  • 2
    I don't believe the spec allows for dropping them, no. As you say, they can be delayed indefinitely which is tantamount to the same thing, but I've never seen it happen. Are you _certain_ there isn't some other logic flaw in your code that makes it appear that they're being dropped? – James Thorpe Jan 05 '16 at 11:55
  • 1
    They do not get lost, when the page is not active (another tab is focused) their behavior changes. http://stackoverflow.com/questions/15871942/how-do-browsers-pause-change-javascript-when-tab-or-window-is-not-active – epascarello Jan 05 '16 at 12:04
  • @JamesThope Thanks, it's hard to be certain about any code but it's one of the first things we checked so we're about as certain as we're going to get. Could perhaps a bug or crash elsewhere in the codebase cause a browser to suspend execution within an entire closure for example? – pn206 Jan 05 '16 at 12:08

0 Answers0