MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / retryAsync

Function retryAsync

scripts/integration/js-api.mjs:619–634  ·  view source on GitHub ↗
(fn, label, attempts, delayMs)

Source from the content-addressed store, hash-verified

617}
618
619async function retryAsync(fn, label, attempts, delayMs) {
620 let lastError;
621 for (let attempt = 1; attempt <= attempts; attempt += 1) {
622 try {
623 return await fn();
624 } catch (error) {
625 lastError = error;
626 if (attempt < attempts) {
627 await sleep(delayMs);
628 }
629 }
630 }
631 throw new Error(
632 `${label} failed after ${attempts} attempts: ${lastError?.message ?? lastError}`,
633 );
634}
635
636function retrySync(fn, label, attempts, delayMs) {
637 let lastError;

Callers 1

mainFunction · 0.70

Calls 1

sleepFunction · 0.70

Tested by

no test coverage detected