Here is an edge case bug that we found in our production code. In the new Promise() constructor, if the resolve callback is called twice with another promise, then the second call to resolve overwrites the first call. A simple test case:
//comment out this line to test native version
const Promise = require('yaku');
const firstValue = Promise.resolve('correct');
const testPromise = new Promise(resolve => {
resolve(firstValue); //first resolve another promise
resolve('wrong'); //then resolve a value
});
//this line should log `correct`, but logs `wrong`
testPromise.then(x => console.log(x));
This only seems to happen when firstValue is a promise, when it's just the string 'correct' the code works the same as the native Promise implementation.
As I said at the beginning, this is an edge case bug, as calling resolve multiple times is not good, but we had an issue with this in production (we use polyfill.io for IE11 support), so I thought I'd at least let you know of the issue.
Here is an edge case bug that we found in our production code. In the
new Promise()
constructor, if the resolve callback is called twice with another promise, then the second call toresolve
overwrites the first call. A simple test case:This only seems to happen when
firstValue
is a promise, when it's just the string'correct'
the code works the same as the native Promise implementation.As I said at the beginning, this is an edge case bug, as calling
resolve
multiple times is not good, but we had an issue with this in production (we use polyfill.io for IE11 support), so I thought I'd at least let you know of the issue.