Add timeout for replica requests on non replica too

This commit is contained in:
Ajay
2022-07-22 20:00:38 -04:00
parent ad7080d801
commit 9764c01428
2 changed files with 20 additions and 3 deletions

View 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);
});
}