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

Function saveWithRetry

scripts/tx_sync.js:427–438  ·  view source on GitHub ↗
(resource, arg1, arg2)

Source from the content-addressed store, hash-verified

425// This retries a `save` call if we get an error like:
426// 500 - Something went wrong, please try again
427function saveWithRetry(resource, arg1, arg2) {
428 return resource.save(arg1, arg2)
429 .catch(err => {
430 console.error(err);
431 if (err.statusCode === 500 || err.statusCode === 429 || err.code === 'ETIMEDOUT') { // server error or rate limit
432 return new Promise(r => setTimeout(r, 10000)) // wait 10 sec
433 .then(() => saveWithRetry(resource, arg1, arg2)); // try again
434 } else {
435 throw err;
436 }
437 });
438}

Callers 1

Calls 2

saveMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected