MCPcopy
hub / github.com/zarazhangrui/follow-builders / fetchXWithRetry

Function fetchXWithRetry

scripts/generate-feed.js:530–545  ·  view source on GitHub ↗
(url, options)

Source from the content-addressed store, hash-verified

528}
529
530async function fetchXWithRetry(url, options) {
531 let lastResponse;
532 for (let attempt = 1; attempt <= X_RETRY_ATTEMPTS; attempt++) {
533 try {
534 const res = await fetch(url, options);
535 lastResponse = res;
536 if (!X_RETRY_STATUSES.has(res.status) || attempt === X_RETRY_ATTEMPTS) {
537 return res;
538 }
539 } catch (err) {
540 if (attempt === X_RETRY_ATTEMPTS) throw err;
541 }
542 await sleep(1000 * attempt);
543 }
544 return lastResponse;
545}
546
547async function fetchXContent(xAccounts, bearerToken, state, errors) {
548 const results = [];

Callers 1

fetchXContentFunction · 0.85

Calls 1

sleepFunction · 0.85

Tested by

no test coverage detected