1.0.2 • Published 11 months ago
@exodus/simple-retry v1.0.2
@exodus/simple-retry
Install
yarn add @exodus/simple-retryUsage
import { retry } from '@exodus/simple-retry'
const broadcastTxWithRetry = retry(broadcastFunction, { delayTimesMs: ['10s'] })
const result = await broadcastTxWithRetry(plainTx)It is possible to trap specific errors and mark them as final when retrying is not needed, like:
const broadcastTxWithRetry = retry(
async (plainTx) => {
try {
return await broadcastFunction(plainTx)
} catch (e) {
if (/specific-final-error/i.test(e.message)) e.finalError = true
throw e
}
},
{ delayTimesMs: ['10s'] }
)