MCPcopy Create free account
hub / github.com/facebook/Rapid / saveWithRetry

Function saveWithRetry

scripts/tx_pull.js:531–542  ·  view source on GitHub ↗
(resource, arg1, arg2)

Source from the content-addressed store, hash-verified

529// This retries a `save` call if we get an error like:
530// 500 - Something went wrong, please try again
531function saveWithRetry(resource, arg1, arg2) {
532 return resource.save(arg1, arg2)
533 .catch(err => {
534 console.error(err);
535 if (err.statusCode === 500 || err.statusCode === 429 || err.code === 'ETIMEDOUT') { // server error or rate limit
536 return new Promise(r => setTimeout(r, 10000)) // wait 10 sec
537 .then(() => saveWithRetry(resource, arg1, arg2)); // try again
538 } else {
539 throw err;
540 }
541 });
542}
543
544
545// Returns an object with sorted keys and sorted values.

Callers

nothing calls this directly

Calls 2

saveMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected