MCPcopy Index your code
hub / github.com/NativeScript/SimDeck / retrySimdeckJson

Function retrySimdeckJson

scripts/integration/cli.mjs:766–795  ·  view source on GitHub ↗
(args, label, options = {})

Source from the content-addressed store, hash-verified

764}
765
766async function retrySimdeckJson(args, label, options = {}) {
767 const attempts = options.attempts ?? 6;
768 const delayMs = options.delayMs ?? 2_000;
769 const healthTimeoutMs = options.healthTimeoutMs ?? 60_000;
770 let lastError;
771 for (let attempt = 1; attempt <= attempts; attempt += 1) {
772 try {
773 return simdeckJson(args, options);
774 } catch (error) {
775 lastError = error;
776 if (attempt === attempts) {
777 break;
778 }
779 if (isServiceConnectionError(error)) {
780 logStep(
781 `${label} lost service connection on attempt ${attempt}; waiting for health before retry`,
782 );
783 try {
784 await waitForHealth({ timeoutMs: healthTimeoutMs });
785 } catch (healthError) {
786 lastError = healthError;
787 }
788 }
789 await sleep(delayMs);
790 }
791 }
792 throw new Error(
793 `${label} failed after ${attempts} attempts: ${lastError?.message ?? lastError}`,
794 );
795}
796
797async function retrySimdeckText(args, label, options = {}) {
798 const attempts = options.attempts ?? 6;

Callers 4

mainFunction · 0.70
cliStepFunction · 0.70
ensureFixtureForegroundFunction · 0.70

Calls 5

isServiceConnectionErrorFunction · 0.85
logStepFunction · 0.85
simdeckJsonFunction · 0.70
waitForHealthFunction · 0.70
sleepFunction · 0.70

Tested by

no test coverage detected