@faast/ethereum-payments
Version:
Library to assist in processing ethereum payments, such as deriving addresses and sweeping funds
20 lines • 667 B
JavaScript
import { isMatchingError } from '@faast/ts-common';
import promiseRetry from 'promise-retry';
const RETRYABLE_ERRORS = [
'request failed or timed out',
];
const MAX_RETRIES = 2;
export function retryIfDisconnected(fn, logger) {
return promiseRetry((retry, attempt) => {
return fn().catch(async (e) => {
if (isMatchingError(e, RETRYABLE_ERRORS)) {
logger.log(`Retryable error during ethereum-payments call, retrying ${MAX_RETRIES - attempt} more times`, e.toString());
retry(e);
}
throw e;
});
}, {
retries: MAX_RETRIES,
});
}
//# sourceMappingURL=utils.js.map