title: Using async.each with promises - async each never stops
body: <p>I am building this function in node that is a mix of promises querying a DB and a async each. 
  The issue is that the async.each function never stops. The promise2 function is never triggered.
  Is it an issue in my code or cant an async.each function be mixed with promises?
  Is there a better way to code what I want to do?</p>
  
  <p>Thanks a lot for your help</p>
  
  <pre><code>promise1().then(function(arr1){
    async.each(arr1, function(obj1, callback) {
      build_select_request(obj1).then(function(select_request){
        query_database(select_request).then(function(result){
          if (result){                       
            build_update_request(obj1).then(function(update_request){                        
              do_query(update_request).then(function(result){                                          
                callback(null)
              }, function(error){
                callback(error)
              })
            }, function(error){
              callback(error)
            })
          } else {
            build_insert_request(obj1).then(function(insert_request){            
              do_query(insert_request).then(function(result){                                                                      
                callback(null)
              }, function(error){
                callback(error)
              })
            }, function(error){
              callback(error)
            })
          }
        }, function(error){
          callback(error)
        })
      }, function(error){
        callback(error)
      })
    }, function(err) {
      // if any of the file processing produced an error, err would equal that error
      if (err) {
        // One of the iterations produced an error.
        // All processing will now stop.
        reject(err)
      } else {
        promise2().then(function(success){        
          resolve(success)
        }, function(error){        
          reject(error)
        })
      }
    })
  }, function(error){  
    reject(error)
  })
  </code></pre>