Open baxtersa opened 6 years ago
Maybe I'm missing something, but native Promise.prototype.then
doesn't pass resolve
and reject
parameters to the callback. You only get those with the Promise
constructor.
My variable names might be misleading here, I'll edit them. But Promise.prototype.then
has the signature
(onFulfilled: (value: any) => T1 | PromiseLike<T1>, onRejected: (reason: any) => T2 | PromiseLike<T2>) => Promise<T1 | T2>
So native Promise.prototype.then
gets called with two callbacks (second one optional).
To clarify, these are the user-provided callbacks, not the internal Promise resolve
/reject
functions.
I'm working on this in the context of distributed continuations, which is much harder, but here's a polyfill for
Promise.prototype.then
that works with nativePromises
(probably modulo some error handling).As I work out the rest of promises I'll try to introduce this into stopify.