
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Retry mechanism is now option rich, easy to plugin and supporting all new NodeJS features.
npm i rehit
//Packages
const rehit = require('rehit');
const axios = require('axios');
//Simple retry- retry five times with 1 sec interval
const simpleRehit = async () => {
const [apiError, apiRes] = await rehit(axios.get('http://goog1234525.com'), 5, 1000);
console.log(apiError, apiRes);
}
//skip some case
const skipRehit = async () => {
const [apiError, apiRes] = await rehit(axios.get('http://goog1234525.com'), 5, 1000, {code: 'ENOTFOUND'});
console.log(apiError, apiRes);
}
//on-failure after retry
const onFailureRehit = () => {
rehit(axios.get('http://goog1234525.com'), 5, 1000, {code: 'ENOTFOUND'}, (error) => {
console.log(error.code);
})
}
rehit(api: Promise, count: Number, time: Number, skip: Object, onFailure: Function) => Array
api : The api request should be sent in a promisified manner. For example: axios.get('http://goog1234525.com') .count : This is the number of retries. Just the number is to be passed. Ex. 5 .time : This is the time interval (in ms) between two API request to retry. Ex. 1000 for 1s interval.skip : This is an Object with single key-value pair. The key should be one of the keys of the expected error object. For example, if we pass {code: 'ENOTFOUND'} it will not retry further on getting error having {code: 'ENOTFOUND'}.onFailure : This is a fail over mechanism. One is to define a function what is to be called on the exhaustion of all the retries and api is still returning error.Saikat Bhattacharya ( @saikatbhattacharya )
FAQs
Retry mechanism for Rest APIs
The npm package rehit receives a total of 10 weekly downloads. As such, rehit popularity was classified as not popular.
We found that rehit 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.