Project: chromium Issues People Development process History Sign in
New issue
Advanced search Search tips
Issue 152991 setInterval should clamp the maximum delay
Starred by 2 users Reported by, Sep 28 2012 Back to list
Status: WontFix
Closed: Apr 2016
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug

Sign in to add a comment
Chrome Version       : 22.0.1229.79 m
URLs (if applicable) :
Other browsers tested:
Add OK or FAIL after other browsers where you have tested this issue:
  Firefox 15: FAIL
  IE 9: FAIL

What steps will reproduce the problem?
1. call setInterval with delay greater than 2^31 - 1

What is the expected result?
I expect setInterval to trigger the code after a long delay.  If it can't actually store delays greater than about 25 days, it should clamp to what it can store.

What happens instead?
The delay overflows to a negative number (I assume) and so it clamps to the low end (probably 4ms).

Please provide any additional information below. Attach a screenshot if possible.

Here's a sample test to run:
setInterval(function () { console.log('test') }, 300000000000)

I couldn't find any max in a spec, but I'd expect it to behave more reasonably, especially because it already clamps at the low end.  Probably applies to setTimeout too, but I didn't test there.
Comment 1 by, Sep 29 2012
I also filed a bug at Bugzilla for Firefox:

Here's what Boris Zbarsky says:
== quote ==
The current implementation uses a standard ToInt32 conversion as defined in the ECMA spec to convert the given value to an interval.

And that's the right behavior per spec, which says:

  long setInterval(Function handler, optional long timeout, any... arguments);

"long" in IDL means "signed 32-bit int".

Please feel free to raise this as a spec issue if you think the spec should change, of course.  For example if you think it should use [Clamp] on that argument.
== end quote ==

I wonder how to raise a spec issue.
Comment 2 by, Sep 29 2012
HTML5 spec change request:
Comment 3 by, Oct 1 2012
Labels: -Area-Undefined Area-WebKit WebKit-Core
Project Member Comment 4 by, Mar 10 2013
Labels: -Area-WebKit -WebKit-Core Cr-Content Cr-Content-Core
Project Member Comment 5 by, Apr 5 2013
Labels: -Cr-Content Cr-Blink
Comment 6 by, Jul 15 2015
Labels: -Cr-Content-Core
Labels: -Cr-Blink Cr-Blink-DOM
Status: Assigned
Comment 9 by, Apr 18 2016
Status: WontFix
> HTML5 spec change request:

This was rejected.

Sign in to add a comment