New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
eachSeries should finish if underlying array is modified #1393
Comments
This behaviour was removed to align with I would consider using queue instead of |
Ah yes queue seems a good candidate for my use case, thx 👍 . If you are open to a PR for the docs, where in the docs do you think it would be the most relevant ? |
Good question. It would be really tedious to note that detail in each of the collections methods. How about in the Collections section header, defined in |
Yes, the Collections section headers looks like a good place for it, though I think many users, as I do, only use the search field, and are not aware of the section header (to be frank, I never thought about clicking in the Collections word). |
Hi, I've been working with Async today and have come across this as well. I am struggling to understand how I could use queue to try and achieve this? (beginner, be kind) var pages = ['1']; // Start with page 1, additional pages are added to this array per iteration
var records = [];
// Now loop through each of the pages
async.eachSeries(pages, function(value, callback){
// Configure the request options
console.log(value);
var options = {
url: 'https://forms.logiforms.com/api/1.0/form/' + formId + '/data?page=' + value,
method: 'GET',
json: true,
proxy: proxyAuthenticationString,
headers: {
'Authorization': apiKey
}
};
// Now complete the request
request(options, function(err, res, body) {
// Something went wrong
if (err) {
logger.info(err);
callback('ERROR', null);
};
// All went as planned, push into objects
pages.push(body.data.next_page);
logger.info(pages);
logger.info(body.data.next_page);
callback(null, body);
});
}, function(err){
}
) |
@nakiabrewer |
What version of async are you using?
2.2.0
Which environment did the issue occur in (Node version/browser version)
nodejs 7.7.3
What did you do? Please include a minimal reproducable case illustrating issue.
What did you expect to happen?
According to changelog v1.10 : eachSeries and family will finish if the underlying array is modified during execution (#557)
I did not find more recent reference to this topic.
So I expected the iteration to stop after have modified the array
What was the actual result?
The iterations continue, but only according to the original length of the array
FWIW, I need to add elements (and so iterations) to the array while iterating, that's why I was testing this behaviour.
The text was updated successfully, but these errors were encountered: