So I thought I can use Promise.method()
from bluebird to replace the trycatch lib I've been using.
Unfortunately, it seems to not catch a thrown error from a setTimeout.
I have something along these lines
function run()
{
var p = Promise.pending()
var inner = Promise.method(function()
{
//some code that could potentially get stuck
setTimeout(function $timeoutTaskKill() {
if (p.promise.isPending())
{
var duration = moment.duration(taskTimeout).seconds();
throw new Error(util.format('timeout has been reached: %ss', duration));
}
}, taskTimeout)
});
//pseudo
inner().then(p.reject, p.resolve);
return p.promise;
}
It crashes my process. When I used the trycatch library instead of Promise.method
, it caught the error.