Looks like Promise.mapSeries will iterate all items before return
See original GitHub issueAccording to the documentation:
The iterator won’t be called for an item until its previous item, and the promise returned by the iterator for that item are fulfilled.
But in my test, the given Iteratable
will be called unconditional even there’s promise be rejected. This’s my test script (Bluebird v3.1.1):
var bluebird = require('bluebird');
var myIterable = {};
myIterable[Symbol.iterator] = function* () {
console.log('Yield first item');
yield bluebird.reject(new Error('first item rejected'));
console.log('Yield second item');
yield bluebird.resolve('some value');
};
bluebird.mapSeries(myIterable, i => i)
.then(items => {
console.log('Items:', items);
})
.catch(err => {
console.log('Some error: %s', err.message);
});
Expect output:
Yield first item
Some error: first item rejected
Actual output:
Yield first item
Yield second item
Some error: first item rejected
Point out me if I have any misunderstanding, thanks.
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Promise.mapSeries - Bluebird JS
The mapper returns a promise or a thenable, it is awaited before continuing to the next iteration. The current element of the iteration...
Read more >Promise each with return value - node.js - Stack Overflow
You are looking for Promise.map . Or if you want to ensure a sequential execution, Promise.mapSeries (since v3.0.1).
Read more >Bluebird.mapSeries - Javascript - Tabnine
The iterator won't be called for an item until its previous item, and the promise returned by the iterator for that item are...
Read more >native-promise-util/map-series.md at main - GitHub
The mapper returns a promise or a thenable, it is awaited before continuing to the next iteration. The current element of the iteration...
Read more >async - Documentation - GitHub Pages
A callback which is called as soon as any iteratee returns true , or after all the iteratee functions have finished. Result will...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Very thankful for this example!