MCPcopy
hub / github.com/lingodotdev/lingo.dev / execWithRetry

Function execWithRetry

packages/cli/src/cli/utils/exec.ts:47–63  ·  view source on GitHub ↗
(
  fn: () => Promise<any>,
  options: ExecWithRetryOptions = ExecWithRetrySchema.parse({}),
)

Source from the content-addressed store, hash-verified

45export type ExecWithRetryOptions = Z.infer<typeof ExecWithRetrySchema>;
46
47export async function execWithRetry(
48 fn: () => Promise<any>,
49 options: ExecWithRetryOptions = ExecWithRetrySchema.parse({}),
50) {
51 let lastError: any;
52
53 for (let i = 0; i < options.attempts; i++) {
54 try {
55 return await fn();
56 } catch (error: any) {
57 lastError = error;
58 await delay(options.delay);
59 }
60 }
61
62 throw lastError;
63}
64
65// Helpers
66

Callers

nothing calls this directly

Calls 3

fnFunction · 0.85
delayFunction · 0.85
parseMethod · 0.80

Tested by

no test coverage detected