refactor(server/utils): avoid same variable name for error in timeLimit

rename the error created in timeLimit to `errorTimeLimit` to differentiate it from the error that is caught inside the promise

makes it a bit easier to quickly distinguish these
This commit is contained in:
Panagiotis Papadopoulos 2025-01-31 07:43:01 +01:00
parent 9eeedc827c
commit 9a8a27c02c

View File

@ -209,7 +209,7 @@ export function timeLimit<T>(promise: Promise<T>, limitMs: number, errorMessage?
}
// better stack trace if created outside of promise
const error = new Error(errorMessage || `Process exceeded time limit ${limitMs}`);
const errorTimeLimit = new Error(errorMessage || `Process exceeded time limit ${limitMs}`);
return new Promise((res, rej) => {
let resolved = false;
@ -224,7 +224,7 @@ export function timeLimit<T>(promise: Promise<T>, limitMs: number, errorMessage?
setTimeout(() => {
if (!resolved) {
rej(error);
rej(errorTimeLimit);
}
}, limitMs);
});