[Bug 22982] New: Synchronous flag and stack consumption of DOM/Promises

https://www.w3.org/Bugs/Public/show_bug.cgi?id=22982
 Bug ID: 22982
 Summary: Synchronous flag and stack consumption of DOM/Promises
 Classification: Unclassified
 Product: WebAppsWG
 Version: unspecified
 Hardware: All
 OS: All
 Status: NEW
 Severity: normal
 Priority: P2
 Component: DOM
 Assignee: annevk@annevk.nl
 Reporter: yhirano@google.com
 QA Contact: public-webapps-bugzilla@w3.org
 CC: mike@w3.org, www-dom@w3.org
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 < N; ++i) {
 promise = promise.then(function() {console.log(id++)});
}
resolver.resolve(4);
Promise.every(Promise.every(...(Promise.every(promise))...)) has the same
problem.
-- 
You are receiving this mail because:
You are on the CC list for the bug.

Received on Friday, 16 August 2013 04:40:34 UTC

AltStyle によって変換されたページ (->オリジナル) /