<?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>22982</bug_id>
          
          <creation_ts>2013-08-16 04:40:33 +0000</creation_ts>
          <short_desc>Synchronous flag and stack consumption of DOM/Promises</short_desc>
          <delta_ts>2013-09-06 15:33:05 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>DOM</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>MOVED</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="Yutaka Hirano">yhirano</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>mike</cc>
    
    <cc>mounir</cc>
    
    <cc>www-dom</cc>
    
    <cc>yusukesuzuki</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>92136</commentid>
    <comment_count>0</comment_count>
    <who name="Yutaka Hirano">yhirano</who>
    <bug_when>2013-08-16 04:40:33 +0000</bug_when>
    <thetext>fulfill, resolve and reject algorithms take the synchronous flag.
If it is set the callbacks are processed synchronously i.e. simply called.
If we chain promises and fulfill the original resolver, the promises will be resolved synchronously, which means stack frames in proportion to the length of the chain will be consumed.

For example, the following statements leads to a stack overflow error in Chrome.

var resolver;
var id = 0;
var N = 10000;
var promise = new Promise(function(r) {resolver = r;});
for (var i = 0; i &lt; N; ++i) {
  promise = promise.then(function() {console.log(id++)});
}
resolver.resolve(4);

Promise.every(Promise.every(...(Promise.every(promise))...)) has the same problem.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93114</commentid>
    <comment_count>1</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2013-09-06 15:33:05 +0000</bug_when>
    <thetext>This is solved by the replacement hosted here: https://github.com/domenic/promises-unwrapping</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>