js-promise-library icon indicating copy to clipboard operation
js-promise-library copied to clipboard

MyPromise statics are subject to array manipulation.

Open WORMSS opened this issue 3 years ago • 0 comments

Test case 1

const waitP = new MyPromise(r => setTimeout(r, 2000));
const arr = [waitP];
MyPromise.all(arr).then(() => console.log('I am finished'), () => console.log('I failed'));
arr.push(0);

// Observe this never resolves.

Test case 2

const waitP = new MyPromise(r => setTimeout(r, 2000));
const longWaitP = new MyPromise(r => setTimeout(r, 20000000));
const arr = [waitP, longWaitP];
MyPromise.all(arr).then(() => console.log('I am finished WAY before 5 hours'), () => console.log('I failed'));
arr.length = 1;

// Observe this resolves insanely early.

WORMSS avatar May 06 '22 09:05 WORMSS