MCPcopy Create free account
hub / github.com/Superflows-AI/superflows / exponentialRetryWrapper

Function exponentialRetryWrapper

lib/utils.ts:24–48  ·  view source on GitHub ↗
(
  func: (...args: Args) => Promise<Output>,
  args: Args,
  retries: number,
)

Source from the content-addressed store, hash-verified

22}
23
24export async function exponentialRetryWrapper<Args extends Array<any>, Output>(
25 func: (...args: Args) => Promise<Output>,
26 args: Args,
27 retries: number,
28): Promise<Output> {
29 const t1 = Date.now();
30 try {
31 const res = await func(...args);
32 console.log(
33 `Exponential retry wrapper completed in ${
34 Date.now() - t1
35 } ms. Retries remaining: ${retries - 1}`,
36 );
37 return res;
38 } catch (error) {
39 console.log(`Error in exponentialRetryWrapper. The error is: ${error}}`);
40 if (retries > 0) {
41 console.log(`Retrying ${func.name} in ${2 ** (10 - retries)}ms`);
42 await new Promise((r) => setTimeout(r, 2 ** (10 - retries)));
43 return await exponentialRetryWrapper(func, args, retries - 1);
44 } else {
45 throw error;
46 }
47 }
48}
49
50export function unpackAndCall(
51 func: ((...args: any[]) => any) | undefined,

Callers 15

handlerFunction · 0.90
handlerFunction · 0.90
handlerFunction · 0.90
getMockedPropertiesFunction · 0.90
getRelevantDocChunksFunction · 0.90
embedDocsFromUrlFunction · 0.90
embedTextFunction · 0.90
summariseChatHistoryFunction · 0.90
BertieFunction · 0.90
LLMPreProcessFunction · 0.90
filterActionsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected