When the await throws an exception that's not caught by a try/catch, the
promise returned by the `async function` ends up rejected - and you have
the identical scenario as a promise with an unhandled rejection.

node has been discussing adding "crash on garbage collection of an
unhandled rejection", but the reason this is possible for them to add is
because by the time something gets garbage collected, nothing in JS can
possibly add a later catch handler - and this would cover promises and
async functions *identically*.

In other words, async/await *in no way whatsoever* changes the discussion
around unhandled promise rejections.

On Sat, Oct 15, 2016 at 11:09 AM, Jordan Rome <jor...@jordanrome.com> wrote:

>
> On Fri, Oct 14, 2016 at 11:25 AM, Alan Johnson <a...@breakrs.com> wrote:
>
>> Having unexpected errors be silently swallowed is definitely a
>> problematic property of promises, which you have to guard against.
>
>
> I didn't think this was the case with await. If a promise rejection is not
> caught the await throws an exception and doesn't execute code below in the
> async function. Also, I believe Node is soon adding support for killing the
> process if a rejected Promise is not caught before it's garbage collected.
> If this is true why the importance of using try/catch with await, don't we
> want programmer errors to be noisy so we can fix them?
>
> --
> Best,
>
> Jordan Rome
> www.jordanrome.com
>
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to