Async functions not friendly to promise extensions

Matthias welp boekewurm at
Fri Apr 14 10:17:22 UTC 2017

resend/fwd of accidental personal reply

Hello Medikoo,

You seem to misunderstand what async functions do to be async. Your
function has the same product as the following:

new Promise((acc, rej) => acc(extendedPromise))

A promise that resolves to a extendedPromise instance. By no means do async
functions use the returned values as their way of determining what type of
promise they are: that'd break when using multiple returns with different

I hope this explains it a bit for you.


On 14 Apr 2017 09:58, "medikoo" < at> wrote:

While Promise methods and functions are friendly for it's extensions (or
even not direct extensions but just thenables), the async function will
always normalize it's result to instance of Promise, even it's
ExtendedPromise, e.g.: class ExtendedPromise extends Promise {}; var
extendedPromise = new ExtendedPromise(function (resolve) { resolve(); });
extendedPromise.then().constructor === ExtendedPromise // true var asyncFn
= async function () { return extendedPromise; }; asyncFn().constructor ===
ExtendedPromise // false asyncFn().constructor === Promise // true That
makes it cumbersome if we work with promise extensions. What was the
reasoning behind such design? If not thenables in general, the promise
extensions I believe should be passed through (or copied via its
View this message in context: Async functions not friendly to promise
Sent from the Mozilla - ECMAScript 4 discussion mailing list archive

es-discuss mailing list
es-discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list