This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
The timeout is currently defined as a signed 32-bit int (aka "long"). I recently ran into a case where some code overflowed this int. In all cases I found, the browsers treated the timeout as 0 (or possibly 4-10ms). It seems reasonable that if the spec says to clamp small values to 4ms, then it would be nice to clamp large values to the something useful like the maximum allowed value (2^31 - 1). It might also make sense to change from long to unsigned long, but that's a different issue. Here's the sample code that got me in trouble: setInterval(function () { console.log('test') }, 300000000000) Here's where I filed an issue with Mozilla: https://bugzilla.mozilla.org/show_bug.cgi?id=795373 and Chromium: http://code.google.com/p/chromium/issues/detail?id=152991
Given that all browsers agree here, I would worry about web compat issues with changes. In particular, I'm >70% confident that using unsigned long would break sites that currently pass "-1" to setTimeout and expect that to mean "as soon as possible", because it would suddenly mean "never".
Would it be possible to clamp before doing ToUint32, so -1 would become 4 before underflowing? If that's not possible, then I agree that the type change isn't worth all of the problems. That aside, does clamping the max make sense?
> Would it be possible to clamp before doing ToUint32 Yes, using [Clamp]. That might be a reasonable thing to do, generally speaking, if we're not worried about sites that are passing in large numbers and expecting immediate firing.
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the Editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the Tracker Issue; or you may create a Tracker Issue yourself, if you are able to do so. For more details, see this document: http://dev.w3.org/html5/decision-policy/decision-policy.html Status: Rejected Change Description: No spec change. Rationale: Given that all browsers currently interoperate, I don't think we should risk the compat risk. The extant Web corpus has all sorts of crazy values being passed to setTimeout.