MCPcopy Create free account
hub / github.com/OneNoteDev/WebClipper / execWithRetry

Function execWithRetry

src/scripts/promiseUtils.ts:25–42  ·  view source on GitHub ↗
(func: () => Promise<T>, retryOptions: RetryOptions = { retryCount: 3, retryWaitTimeInMs: 3000 })

Source from the content-addressed store, hash-verified

23 * Executes the given function and retries on failure.
24 */
25 export function execWithRetry<T>(func: () => Promise<T>, retryOptions: RetryOptions = { retryCount: 3, retryWaitTimeInMs: 3000 }): Promise<T> {
26 return func().catch((error1) => {
27 if (retryOptions.retryCount > 0) {
28 return new Promise<T>((resolve, reject) => {
29 setTimeout(() => {
30 retryOptions.retryCount--;
31 execWithRetry(func, retryOptions).then((response) => {
32 resolve(response);
33 }).catch((error2) => {
34 reject(error2);
35 });
36 }, retryOptions.retryWaitTimeInMs);
37 });
38 } else {
39 return Promise.reject(error1);
40 }
41 });
42 }
43}

Callers

nothing calls this directly

Calls 1

funcFunction · 0.85

Tested by

no test coverage detected