<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>19143</bug_id>
          
          <creation_ts>2012-09-29 15:13:30 +0000</creation_ts>
          <short_desc>setTimeout and setInterval should clamp at the maximum timeout value</short_desc>
          <delta_ts>2012-12-05 21:01:35 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>HTML5 spec</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Aaron McBride">nogwater</reporter>
          <assigned_to name="Edward O&apos;Connor">eoconnor</assigned_to>
          <cc>bzbarsky</cc>
    
    <cc>eoconnor</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>74881</commentid>
    <comment_count>0</comment_count>
    <who name="Aaron McBride">nogwater</who>
    <bug_when>2012-09-29 15:13:30 +0000</bug_when>
    <thetext>The timeout is currently defined as a signed 32-bit int (aka &quot;long&quot;).  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&apos;s a different issue.

Here&apos;s the sample code that got me in trouble:
setInterval(function () { console.log(&apos;test&apos;) }, 300000000000)

Here&apos;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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74884</commentid>
    <comment_count>1</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2012-09-29 15:32:25 +0000</bug_when>
    <thetext>Given that all browsers agree here, I would worry about web compat issues with changes.

In particular, I&apos;m &gt;70% confident that using unsigned long would break sites that currently pass &quot;-1&quot; to setTimeout and expect that to mean &quot;as soon as possible&quot;, because it would suddenly mean &quot;never&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74885</commentid>
    <comment_count>2</comment_count>
    <who name="Aaron McBride">nogwater</who>
    <bug_when>2012-09-29 16:06:21 +0000</bug_when>
    <thetext>Would it be possible to clamp before doing ToUint32, so -1 would become 4 before underflowing?  If that&apos;s not possible, then I agree that the type change isn&apos;t worth all of the problems.  That aside, does clamping the max make sense?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79135</commentid>
    <comment_count>3</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2012-11-29 17:37:29 +0000</bug_when>
    <thetext>&gt; Would it be possible to clamp before doing ToUint32

Yes, using [Clamp].  That might be a reasonable thing to do, generally speaking, if we&apos;re not worried about sites that are passing in large numbers and expecting immediate firing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79504</commentid>
    <comment_count>4</comment_count>
    <who name="Edward O&apos;Connor">eoconnor</who>
    <bug_when>2012-12-05 21:01:35 +0000</bug_when>
    <thetext>EDITOR&apos;S RESPONSE: This is an Editor&apos;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&apos;t think
we should risk the compat risk. The extant Web corpus has all sorts of
crazy values being passed to setTimeout.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>