Closed Er-rchydy closed 6 years ago
So basically it's because the Promise.all
is taking care of setting the items in the right place. The array push does it in the order at which it arrives, which is why it's non-sequential. Although Promise.all
has its output array matching the input promises :)
Have a look at that example
const arr = []
const p0 = new Promise((resolve, reject) => setTimeout(() => {
arr.push('foo1')
resolve('foo1')
}, 1000))
const p1 = new Promise((resolve, reject) => setTimeout(() => {
arr.push('foo2')
resolve('foo2')
}, 100))
Promise.all([p0, p1]).then(values => {
console.log('yay in the right order!', values)
console.log('oh noes', arr)
})
I found an issue in
wtManifest.js
, how to make sure we always remove the oldest magnet ? because of every chunk takes different time to get it's magnet, themagnetsOrder
array is not always in a good order.if we have a manifest that has 5 chunks, we got :
so instead of
we got
and that causes removing newest chunks that we need instead of removing the oldest one. how can we prevent this issue. thanks