Skip to content

Commit

Permalink
refactor(server/utils): avoid same variable name for error in timeLimit
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pano9000 committed Jan 31, 2025
1 parent 83bf55b commit 697bda1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/services/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -224,7 +224,7 @@ export function timeLimit<T>(promise: Promise<T>, limitMs: number, errorMessage?

setTimeout(() => {
if (!resolved) {
rej(error);
rej(errorTimeLimit);
}
}, limitMs);
});
Expand Down

0 comments on commit 697bda1

Please sign in to comment.