I am using Javascript Promises for the first time and ran into something I don't understand.
What I am trying to do is create a validation phase which runs around and checks things - eventually waiting for all promises to resolve.
To do this, I create a validation promise:
validate = function(data) {
var p = new Promise(function(resolve, reject)){
Here I define a promises array for all the different things I will be doing:
var all_promises = Array();
Now do things like this Sequelize call while adding promises into this array (Sequelize returns promises):
all_promises.push(resBooking);
resBooking.count(...).then(...).catch(...);
I have logging statements that demonstrate we got through then and everything is dandy. Now all I need to do is wait!
Promise.all(all_promises).then(function(){
p.resolve();
});
But this silly thing hangs - it waits for something to complete. No CPU usage. What am I doing wrong?