![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
@dyaa/async-retry
Advanced tools
We needed a utility that helps us to retry an async function on it's Failure/Rejection and to be able to control the number of retries and the time interval between each retry also to block the retries in case of some logic provided.
yarn add @dyaa/async-retry
Or if you prefer npm!
npm i @dyaa/async-retry
import asyncRetry from '@dyaa/async-retry';
asyncRetry
expects two parameters
Promise
.Options | Type | Optional? | Default | Description |
---|---|---|---|---|
retries | number | :heavy_check_mark: | 5retries | number of retries |
interval | number | :heavy_check_mark: | 5000ms | base interval between retries |
dontRetry | function | :heavy_check_mark: | () => false | A function that returns a boolean value. This boolean value is to check if we want the retry to continue or not |
onComplete | function | :heavy_check_mark: | null | A hook function that's called on the completion of the retry also provides (err, count) in params |
onFailure | function | :heavy_check_mark: | null | A hook function that's called on the failure of the retry also provides (err) in params |
onRetry | function | :heavy_check_mark: | null | A hook function that's called on every retry also provides (err, count) in params |
import asyncRetry from '@dyaa/async-retry';
const tryFetch = () => fetch('http://www.mocky.io/v2/5c59705d320000f31eba3880')
.then(res => {
if (res.status !== 200) {
return Promise.reject(new Error(`Rejected because of statusCode is ${res.status}`));
}
return res.json();
}).catch(e => Promise.reject(new Error(e)));
asyncRetry(tryFetch, {
retries: 3,
onRetry: (err, count) => console.log(`#### Retry #${count} with ${err}.`),
onComplete: count => console.log(`#### Completed after ${count} retries.`),
onFailure: err => console.log(`#### Failed because ${err}.`),
})
.then(response => {
console.log({response})
})
.catch(console.error);
FAQs
Async retry with hooks
The npm package @dyaa/async-retry receives a total of 0 weekly downloads. As such, @dyaa/async-retry popularity was classified as not popular.
We found that @dyaa/async-retry demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.