mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-25 08:58:23 +03:00
Add timeout for replica requests on non replica too
This commit is contained in:
11
src/utils/promiseTimeout.ts
Normal file
11
src/utils/promiseTimeout.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export function promiseTimeout<T>(promise: Promise<T>, timeout: number): Promise<T> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (timeout) {
|
||||
setTimeout(() => {
|
||||
reject(new Error("Promise timed out"));
|
||||
}, timeout);
|
||||
}
|
||||
|
||||
promise.then(resolve, reject);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user