W3C home > Mailing lists > Public > whatwg@whatwg.org > September 2014

Re: [whatwg] An API for unhandled promise rejections

From: Domenic Denicola <domenic@domenicdenicola.com>
Date: Fri, 12 Sep 2014 20:07:59 +0000
To: Boris Zbarsky <bzbarsky@mit.edu>, "whatwg@lists.whatwg.org" <whatwg@lists.whatwg.org>
Message-ID: <f5b90342dbd54b2daa8362ffc2cc0e4a@BN1PR05MB325.namprd05.prod.outlook.com>
From: whatwg [mailto:whatwg-bounces@lists.whatwg.org] On Behalf Of Boris Zbarsky

>> In this case the event would be fired
> By "the" event do you mean the error event or the rejectionhandled event?

Ah, trick question! Because, see, I was confused when I wrote that, and myself did not know!

>> but no listener would be present at that time, so "got here" would not be logged.
> In my mental model based on your initial mail here, the rejectionhandled event would get fired at the point when catch() is called, which is after window.onrejectionhandled is set.

You are totally right.

To state what happens in that scenario more clearly:

- `error` is fired at time zero. Nobody is listening.
- `rejectionhandled` is fired at time 200 ms. Somebody is listening, and "got here" is logged.

So to answer the original question:

> If there is no listener for either when the promise would normally fire error, but then a listener for "rejectionhandled" gets added before a .catch() call on the promise, does the listener get called?

Yes, yes it does. Sorry about the massive confusion. I should probably stop writing emails for the night :).
Received on Friday, 12 September 2014 20:08:27 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:23 UTC