small changes for better debugging infos

This commit is contained in:
zadam
2021-02-20 23:17:29 +01:00
parent 081b8b126a
commit fbbd51d0b1
5 changed files with 38 additions and 27 deletions

View File

@@ -296,9 +296,13 @@ function dynamicRequire(moduleName) {
}
}
function timeLimit(promise, limitMs) {
function timeLimit(promise, limitMs, errorMessage) {
if (!promise || !promise.then) { // it's not actually a promise
return promise;
}
// better stack trace if created outside of promise
const error = new Error('Process exceeded time limit ' + limitMs);
const error = new Error(errorMessage || `Process exceeded time limit ${limitMs}`);
return new Promise((res, rej) => {
let resolved = false;