
Research
/Security News
Mini Shai-Hulud Campaign Hits Red Hat Cloud Services npm Packages
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.
retryx (ritrɪ́ks) is a Promise-based retry workflow library.
$ npm install --save retryx

retryxretryx(main [, options [, ...args]])
main is a function returns Promise that might be rejected. Required
options is a object contains maxTries, waiter and other hooks. Optional
...args will be passed to main function call. Optional
options{
maxTries: number,
timeout: number,
waiter: HookFunction,
retryCondition: HookFunction,
beforeTry: HookFunction,
afterTry: HookFunction,
beforeWait: HookFunction,
afterWait: HookFunction,
doFinally: HookFunction,
}
HookFunction can receive current try count and last reject reason as arguments. See source.
maxTriesAttempts calling main function specified times or until succeeds.
Set -1 to retry unlimitedly.
default: 5
timeoutSets the timeout.
Set -1 to no timeout.
default: -1
waiterHook function called before each retry. It's meant to return a Promise that resolves after specific duration.
default: exponential backoff. 200ms, 400ms, 800ms, 1600ms and so on.
See default waiter implementation. You can create custom waiter with wait function for shorthand.
retryConditionHook function called AFTER each try. If it returns falsy value, retrying will be abandoned even not reaching maxTries.
default: always return true
beforeTryHook function called BEFORE each try.
default: nothing to do
afterTryHook function called AFTER each try.
default: nothing to do
beforeWaitHook function called BEFORE each wait.
default: nothing to do
afterWaitHook function called AFTER each wait.
default: nothing to do
doFinallyHook function called ONCE whether main function resolved or rejected.
default: nothing to do
You can create a new instance of retryx with a custom config.
retryx.create(options)
const myRetryx = retryx.create({
maxTries: 100,
waiter: () => new Promise(r => setTimeout(r, 10)),
});
const retryx = require("retryx");
const AWS = require("aws-sdk");
const ec2 = new AWS.EC2();
retryx(() => ec2.describeRegions().promise()).then(response => {
console.log(response);
});
const retryx = require("retryx");
const axios = require("axios");
retryx(() => axios.get("http://example.com")).then(response => {
console.log(response.statusText);
});
import retryx from "retryx";
(async () => {
try {
const result = await retryx(() => {
const number = Math.round(Math.random() * 100);
if (number > 95) {
return number;
} else {
throw number;
}
});
console.log("success", result);
} catch (n) {
console.log("fail:", n)
}
})();
const retryx = require("retryx");
retryx(() => {
const number = Math.round(Math.random() * 100);
return number > 95 ? Promise.resolve(number) : Promise.reject(number);
}, {
maxTries: 100,
beforeWait: (tries) => console.log(`try #${tries} failed. wait 100 ms`),
waiter: () => new Promise((r) => setTimeout(r, 100)),
}).then(result => {
console.log(`success: ${result}`);
});
import retryx from "retryx";
(async () => {
let result = await retryx(() => 123);
result = "abc"; // ERROR: Type '"abc"' is not assignable to type 'number'.
})();
import retryx from "retryx";
(async () => {
let result = await retryx<string>(() => { // Explicitly specifies type of promised value to return.
const number = Math.round(Math.random() * 100);
if (number < 50) {
throw new Error();
} else if (number < 80) {
return "good";
} else if (number < 90) {
return "great";
} else {
return number; // ERROR: Type 'number' is not assignable to type 'string | Promise<string>'.
}
});
})();
$ git clone
$ cd retryx
$ yarn
Test.
$ yarn test
FAQs
Promise-based retry workflow library.
The npm package retryx receives a total of 151 weekly downloads. As such, retryx popularity was classified as not popular.
We found that retryx 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.

Research
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.

Research
/Security News
The North Korean malware loader hides in a Packagist-listed package and its GitHub branch to fetch and execute remote code in a likely Contagious Interview-style lure.

Security News
The Rust project is moving toward formal rules on LLM use in contributions after months of internal debate over maintainer burden, code quality, and contributor experience.