Wednesday, 7 June 2017

Promise chain not executing in expected order - nodejs

I have a chain of 4 promises, and 1 function at the end. The final function is executing before the previous promises in the chain have resolved.

Can someone explain to me why this might be happening?

Here is the promise chain:

updateGdax(db)
  .then(updateBitstamp(db))
  .then(updateBitfinex(db))
  .then(updatePoloniex(db))
  .then(coinMarketData.updateCoinMarketData(db))
  .then(addRates(db)); //this function is executing after the first promise in the chain.

I would like each function to execute after the one listed before it, so addRates(db) should be executed last.

I can post the code from the promise functions if needed for further analyses, but I really just want to understand WHY this would happen, as my understanding is that functions in a promise chain won't execute unless the previous promise in the chain has resolved.



via chuckieDub

No comments:

Post a Comment