Comment #30 on issue 3093 by dome...@domenicdenicola.com: Debugging promises
http://code.google.com/p/v8/issues/detail?id=3093

Jake: what libraries like Bluebird do is wait until the end of the turn to make any decisions about unhandled or not. So in your particular examples:

var p = new Promise(function(resolve, reject) { reject(new Error('Something went wrong'); });
p.then(function(result) {
   console.log('Promise success', result);
}, function(error) {
  console.error('Promise failed', error);
});

Handled, since by the end of the turn an error handler is attached (and the return value of p.then is fulfilled).

var p = Promise.resolve();
var q = p.then(function onFulfilled() {
  var r = Promise.reject();
  return r;
});

Handled, since during the turn (a) p is fulfilled and so a microtask is queued to run onFulfilled; (b) onFulfilled runs and creates r, which is for-now unhandled; (c) onFulfilled returns, and the algorithm that called onFulfilled takes over, queueing a microtask to run r.then(resolveQ, rejectQ); (d) said microtask happens, making r now handled, and resolving q; (e) turn finally ends, and in we survey and find that p is fulfilled, q is fulfilled, and r is rejected but handled.

Promise.reject().catch(function(){})

Same as the first case, but with less typing.

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to