nodejs async.forEach callback was already called

I'm using the async library to help me with my control flow. I have a collection over wich I want to iterate, for each element execute 1 asynchronous task and when all are done, call the callback.

I've decided to use an async.forEach loop, on each loop I call my asynchronous task but I get an error: callback was already called, but shouldn't the callback be called only when all callbacks are called? And I even wanted to understand properly how to handle errors, it is highly probable that some task will fail and others will succed, I don't need to know wich elements fail, but I would like, how can I do this?

This is my code:

async.forEach(fonts, function(font, callback) {
    ftpm_module.installOsFont(font, callback);
}, function() {
    console.log("finished");
});

EDIT: the error occurs only if I pass 2 or more fonts.

You are passing the forEach callback to your function which is also expecting a callback which is incorrect. You need to give a different callback in your inside function and use the forEach callback separately. The forEach callback is used to tell that the all processing of fonts array is complete and return from the execution. You need to do something like this:

async.forEach(fonts, function(font, callback) {
    ftpm_module.installOsFont(font, function(err){
       // ftpm_module finished getting executed.
       if(err)
          callback(err); 
    });
    //now call the callback function to say that you have finished executing ftpm_module function
    callback();
}, function(err) {
    if(err)
      console.log(err);
    else
      console.log("finished");
});