This commit is contained in:
Andras Schmelczer 2025-12-05 21:48:35 +00:00
commit a5e128efcd
2 changed files with 7 additions and 14 deletions

View file

@ -1,4 +1,3 @@
export async function withTimeout<T>(
promise: Promise<T>,
timeoutMs: number,
@ -7,17 +6,11 @@ export async function withTimeout<T>(
return Promise.race([
promise,
new Promise<T>((_, reject) =>
setTimeout(
() =>
{ reject(
new Error(
`${operationName} timed out after ${timeoutMs}ms`
)
); },
timeoutMs
)
setTimeout(() => {
reject(
new Error(`${operationName} timed out after ${timeoutMs}ms`)
);
}, timeoutMs)
)
]);
}