question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Looks like Promise.mapSeries will iterate all items before return

See original GitHub issue

According 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:closed
  • Created 8 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
petkaantonovcommented, Jan 18, 2016
var bluebird = require('bluebird');

var iterator = bluebird.coroutine(function* () {
  console.log('Yield first item');
  var a = yield bluebird.reject(new Error('first item rejected'));
  console.log('Yield second item');
  var b = yield bluebird.resolve('some value');
  return [a, b];
});

iterator().then(function(items) {

});
0reactions
xiaogaozicommented, Jan 19, 2016

Very thankful for this example!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found