How to check for dangling Promises? (Bluebird.js)

promises

I ran into an issue where I forgot to resolve my promise, leaving the remainder of the chain waiting (Forever). Thankfully in my case I was able to track down the issue in only 10 or so minutes, but I could see this being a really big pain in the butt if I don't figure out some way to check for orphaned promise chains.

How would you automate checking for the following error?

function myAsyncFunction(){
return new Promise((resolve,reject)=>{
  //do stuff here, but forget to call resolve();
});
}

Best Answer

Most people do the check in a regular unit test. You can't test a promise without testing that it resolves and giving it a timeout appropriate to the unit under test.

Related Topic