Skip to content
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

auto final callback gets called too many times in case of exception #410

Closed
ARAtlas opened this issue Nov 19, 2013 · 1 comment
Closed

Comments

@ARAtlas
Copy link

ARAtlas commented Nov 19, 2013

If an exception is thrown in the final callback of an auto, the final callback ends up being called multiple times. In this example, "This should only run once" will be logged twice.

async.auto({
  func1: function(callback) {
    callback(null);
  },

  func2: ['func1',
    function(callback) {
      callback(null);
    }
  ]

},

  // Final callback. This should only run once...
  function(err) {
    console.log("***** This should only run once *****"); //...but somehow this is called twice
    throw new Error("Something goes wrong");
  }
);
th3james added a commit to th3james/async that referenced this issue Dec 2, 2013
@ARAtlas
Copy link
Author

ARAtlas commented Jan 6, 2014

Any thoughts on integrating the above fix? An alternative way to fix it would be to wrap the final callback in a process.nextTick:

process.nextTick(function() {
  callback(null, results);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants