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

Function retryHttpJson

scripts/integration/cli.mjs:1845–1865  ·  view source on GitHub ↗
(method, requestPath, body, label, options = {})

Source from the content-addressed store, hash-verified

1843}
1844
1845async function retryHttpJson(method, requestPath, body, label, options = {}) {
1846 const attempts = options.attempts ?? 3;
1847 const delayMs = options.delayMs ?? 2_000;
1848 let lastError;
1849 for (let attempt = 1; attempt <= attempts; attempt += 1) {
1850 try {
1851 return await httpJson(method, requestPath, body, {
1852 maxElapsedMs: options.maxElapsedMs ?? httpActionBudgetMs,
1853 });
1854 } catch (error) {
1855 lastError = error;
1856 if (attempt === attempts) {
1857 break;
1858 }
1859 await sleep(delayMs);
1860 }
1861 }
1862 throw new Error(
1863 `${label} failed after ${attempts} attempts: ${lastError?.message ?? lastError}`,
1864 );
1865}
1866
1867function httpBuffer(method, requestPath, body, options = {}) {
1868 const payload = body === undefined ? null : Buffer.from(JSON.stringify(body));

Callers 4

httpStepFunction · 0.85
queryUiFunction · 0.85
waitForUiElementFunction · 0.85

Calls 2

httpJsonFunction · 0.70
sleepFunction · 0.70

Tested by

no test coverage detected