Report traceback when waitUntil times out

This commit is contained in:
JC Brand 2020-06-05 15:37:32 +02:00
parent 58d018e868
commit dd7bb28d86

View File

@ -575,6 +575,7 @@ u.waitUntil = function (func, max_wait=300, check_delay=3) {
}
const promise = u.getResolveablePromise();
const timeout_err = new Error();
function checker () {
try {
@ -590,12 +591,16 @@ u.waitUntil = function (func, max_wait=300, check_delay=3) {
}
const interval = setInterval(checker, check_delay);
const max_wait_timeout = setTimeout(() => {
function handler () {
clearTimers(max_wait_timeout, interval);
const err_msg = 'Wait until promise timed out';
const err_msg = `Wait until promise timed out: \n\n${timeout_err.stack}`;
console.trace();
log.error(err_msg);
promise.reject(new Error(err_msg));
}, max_wait);
}
const max_wait_timeout = setTimeout(handler, max_wait);
return promise;
};