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

Function retrySimdeckJson

scripts/integration/webrtc.mjs:286–306  ·  view source on GitHub ↗
(args, label, options = {})

Source from the content-addressed store, hash-verified

284}
285
286async function retrySimdeckJson(args, label, options = {}) {
287 const attempts = options.attempts ?? 3;
288 const delayMs = options.delayMs ?? 2_000;
289 let lastError;
290 for (let attempt = 1; attempt <= attempts; attempt += 1) {
291 try {
292 return simdeckJson(args, options);
293 } catch (error) {
294 lastError = error;
295 if (attempt < attempts) {
296 console.warn(
297 `${label} attempt ${attempt}/${attempts} failed; retrying in ${delayMs}ms: ${error?.message ?? error}`,
298 );
299 await sleep(delayMs);
300 }
301 }
302 }
303 throw new Error(
304 `${label} failed after ${attempts} attempts: ${lastError?.message ?? lastError}`,
305 );
306}
307
308function runJson(command, args, options = {}) {
309 return JSON.parse(runText(command, args, options));

Callers 3

mainFunction · 0.70

Calls 3

warnMethod · 0.80
simdeckJsonFunction · 0.70
sleepFunction · 0.70

Tested by

no test coverage detected