dcl-catalyst-client
Version:
A client to query and perform changes on Decentraland's catalyst servers
25 lines • 949 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.retry = void 0;
async function retry(description, execution, attempts, waitTimeInMs) {
while (attempts > 0) {
try {
return await execution();
// ^^^^^ never remove this "await" keyword, otherwise this function won't
// catch the exception and perform the retries
}
catch (error) {
attempts--;
if (attempts > 0) {
console.info(`Failed to ${description}. Still have ${attempts} attempt/s left. Will try again in ${waitTimeInMs}`);
await new Promise((resolve) => setTimeout(resolve, waitTimeInMs));
}
else {
throw error;
}
}
}
throw new Error('Please specify more than one attempt for the retry function');
}
exports.retry = retry;
//# sourceMappingURL=retry.js.map