Where'd Promise#done go?

Mark S. Miller erights at google.com
Tue Jun 18 20:14:28 PDT 2013


On Tue, Jun 18, 2013 at 8:11 PM, Domenic Denicola <
domenic at domenicdenicola.com> wrote:

> From: Mark S. Miller [mailto:erights at google.com]
>
> > I don't understand this. I am onboard
> with `console.unhandledRejection`/`console.rejectionHandled` and all that
> for better logging, and with using WeakRef notification to improve the
> logging yet further. But I don't see how any of this can substitute for the
> need that .done() serves. I think we will still need .done() in ES7
> promises.
>
> While I think I see what you're getting at,


What do you think I'm getting at? ;)



>  let me play devil's advocate for a bit to draw this out more clearly.
> Using the sample code from
> https://github.com/promises-aplus/unhandled-rejections-spec/issues/1:
>
> ```js
> var rejectPromise;
> var promise = new Promise((resolve, reject) => rejectPromise = reject);
>
> promise.then(() => console.log("I only attached a handler for
> fulfillment"));
> // All is OK (A)
>
> rejectPromise(promise, new Error("who handles me?"));
> // Nobody sees the error! Oh no, maybe we should crash here? (B)
>
> setTimeout(function () {
>     promise.then(undefined, (err) =>console.error("I got it!", err));
>     // But if we crashed there, then how would this code ever get run? (C)
> }, 5000);
> ```
>
> Using a `done`-less promise implementation with a unhandled rejections
> console, we have the flow that:
>
> 1. At line (A), all is fine, and the unhandled rejections console is empty.
> 2. At line (B), the unhandled rejections console contains `Errror: "who
> handles me?"`. This remains true for the next five seconds.
> 3. At line (C), after five seconds have passed, the unhandled rejections
> console becomes yet again empty.
>
> This seems to neatly solve the problem without `done`, at least in my
> devil's-advocate world. Where's the problem? :)
>



-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130618/e9cbe421/attachment.html>


More information about the es-discuss mailing list