creationix/step — pull request #40 by broofa (2012-10-15 15:01:31+00:00)
Title: empty group()s should not complete automatically.

If the steps for a group are defined asynchronous to the `this.group()` call (i.e. subsequent to the `check()` call scheduled by `next.group`), localCallback() ends up being called prematurely since no functions have been added to the group yet.

The specific case where I ran into this was when trying to do the following, where the `group()` call appears in the callback to an intermediate, async, function:

step(
function () {
var group = this.group();

LIST_OF_STATES.forEach(function(state) {
// intermediate async action
request('url_get_counties_by_state', function(err, countiesInfo) {
countiesInfo.forEach(function(county) {
save_to_db(county, group()); // group here
}
});
});
},
function (err, counties) {
// print out list of all counties in all states
}
);

(Note: This is slightly problematic in the case where `this.group()` is called in anticipation of some work being done, but where it's later discovered that there's no actual work needed. However that seems like even more of an edge case then the above, where work is being scheduled asynchronously.)