New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

httplease-retry

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

httplease-retry - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

15

lib/retryFilter.js
'use strict';
const populateHttpOptions = require('httplease/lib/populateHttpOptions');
function delay(ms) {

@@ -15,9 +13,6 @@ return new Promise((resolve) => setTimeout(resolve, ms));

return function retryFilter(requestConfig, next) {
function retryFilter(requestConfig, next) {
function tryOnce(attempts) {
requestConfig.baseUrl = baseUrlList[(attempts - 1) % baseUrlList.length];
requestConfig.httpOptions = requestConfig.httpOptions || {};
delete requestConfig.httpOptions.protocol;
requestConfig.headers = requestConfig.headers || {};
return populateHttpOptions(requestConfig, next).catch((err) => handleFailure(err, attempts));
return next(requestConfig).catch((err) => handleFailure(err, attempts));
}

@@ -34,5 +29,9 @@

return tryOnce(1);
};
}
retryFilter.order = -10;
return retryFilter;
}
module.exports = createRetryFilter;
{
"name": "httplease-retry",
"version": "0.1.1",
"version": "0.2.0",
"description": "Retry filter for httplease",

@@ -39,3 +39,3 @@ "main": "index.js",

"eslint": "^3.3.0",
"httplease": "^0.5.0",
"httplease": "^0.5.2-beta1",
"istanbul": "^0.4.3",

@@ -42,0 +42,0 @@ "jasmine": "^2.4.1",

@@ -5,2 +5,5 @@ ![build-status](https://bitbucket-badges.atlassian.io/badge/atlassianlabs/httplease-retry.svg)

Request retries with optional fallback to alternate servers as an [httplease](https://bitbucket.org/atlassianlabs/httplease) filter.
# Usage guide

@@ -25,3 +28,3 @@

const retryConfig = {
shouldRetryFn: () => true,
shouldRetryFn: (err, attempts, url) => true,
maxAttempts: 2,

@@ -42,3 +45,3 @@ retryDelayMillis: 50,

httpClient
.withPath('/post')
.withPath('/some-resource')
.withMethodGet()

@@ -45,0 +48,0 @@ .send();

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc