Where'd Promise#done go?

Kevin Smith zenparsing at gmail.com
Wed Jun 19 01:46:00 PDT 2013


>
> var rejected = Promise.reject(new Error("bad news!"));
> var fulfilled = Promise.resolve(5);
>
> fulfilled.then(() => {
>     rejected.catch(err => console.error(err));
> });
>
>
In my implementation, this works for two reasons.  First, "root" promises
(i.e. not created via `then`) such as `rejected` above are not "throwable".

Second, errors are not thrown until after the callback queue has been
repeatedly flushed, until empty.  Both arrow functions above would execute
before the next checkpoint.

This, however, would crash the program:

    Promise.reject(new Error("bad news!")).then(x => x);

As would this:

    var rejected = Promise.reject(new Error("bad news!")).then(x => x);
    setTimeout($=> rejected.catch(err => console.log(err)), 0);

{ Kevin }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130619/52c4d85d/attachment-0001.html>


More information about the es-discuss mailing list