tweaks in sync timeout handling

This commit is contained in:
zadam
2020-07-28 23:29:12 +02:00
parent 5f4a84d967
commit 8a57960c6e
3 changed files with 10 additions and 4 deletions

View File

@@ -218,6 +218,9 @@ function formatDownloadTitle(filename, type, mime) {
}
function timeLimit(promise, limitMs) {
// better stack trace if created outside of promise
const error = new Error('Process exceeded time limit ' + limitMs);
return new Promise((res, rej) => {
let resolved = false;
@@ -229,7 +232,7 @@ function timeLimit(promise, limitMs) {
setTimeout(() => {
if (!resolved) {
rej(new Error('Process exceeded time limit ' + limitMs));
rej(error);
}
}, limitMs);
});