domenic / promises-unwrapping

The ES6 promises spec, as per September 2013 TC39 meeting
1.24k stars 95 forks source link

Handle infinite recursion cases? #1

Closed domenic closed 11 years ago

domenic commented 11 years ago
annevk commented 11 years ago

Why is it more important to detect cycles here than with while(1)?

domenic commented 11 years ago

That's a fair question, and the answer may be that it's not. Fixing Resolve(p, p) is a clear win, as it's cheap and prevents var p = fulfilledPromise.then(() => p). But full cycle detection is almost certainly more costly, and might not be a good idea.

To be clear, the scenario that cycle detection would solve would be

var p1 = fulfilledPromise.then(() => p2);
var p2 = fulfilledPromise.then(() => p1);

Cycle detection would consist of rejecting both p1 and p2 with an error (probably a TypeError).

slightlyoff commented 11 years ago

I don't see why this needs fixing at all. Devtools can detect it without any spec changes.

domenic commented 11 years ago

That's a great point. Closing.