Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@yveskaufmann/retry
Advanced tools
Utility for retrying promise based operation on certain situations.
Utility for retrying promise based operation on certain situations.
npm install @yveskaufmann/retry
The example below demonstrates how to annotate
methods to mark them as retryable. When retryWhen
return true
the method is retried until it reaches the
maxRetries
limit.
When the retry limit is reached last result is returned or the last error is thrown.
When the limit is reached the last result, or the last thrown
NOTE: The Retryable annotation only works with methods that returning promises like async methods.
class Service {
@Retryable({
retryWhen: (result, err) => err != null,
delay: Retry.Delays.linear(50),
maxRetries: 3,
})
async retryOnAnyError() {
// ...
}
@Retryable({
retryWhen: (result, err) => err == null && result == false,
delay: Retry.Delays.linear(50),
maxRetries: 3,
})
async retryWhenFalseIsReturned() {
return Math.random() < 0.6;
}
}
This utility can also be used without annotating class methods.
const response = await Retry.do({
operation: () => client.get(...),
retryWhen: (result, err) => HttpError.isTooManyRequest(err)
maxRetries: 3,
delay: Retry.Delays.constant(50),
});
The API is documented in the provided typescript definition file.
FAQs
Utility for retrying promise based operation on certain situations.
We found that @yveskaufmann/retry demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.