Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@capriza/http-utils

Package Overview
Dependencies
Maintainers
3
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@capriza/http-utils - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

10

lib/httpUtils.js

@@ -6,2 +6,3 @@ var axios = require('axios');

const retryStatusCodes = [502, 503, 504];
const networkErrors = ["ECONNABORTED", "ECONNRESET"];

@@ -14,2 +15,3 @@ module.exports = class HttpUtils extends BaseUtils {

this.retryStatusCodes = (Array.isArray(options.retryStatusCodes) && options.retryStatusCodes) || retryStatusCodes;
this.retryOnNetworkErrors = options.retryOnNetworkErrors || false;

@@ -59,5 +61,7 @@ this.requestQueue = new Queue(options.limit, options.interval, options.maxConcurrent);

} catch (ex) {
if(!this.maxRetries || !ex || !ex.response || !this.retryStatusCodes.includes(ex.response.status)) throw ex;
requestLog.error(`[HttpUtils] Got status ${ex.response.status} on ${opts.baseURL || this.baseURL || ""}${url}${retriesCount === 0 ? `. Reached max retries: ${this.maxRetries}` : " Retrying..."}`);
let shouldRetry = false;
if(this.retryOnNetworkErrors && ex.code && networkErrors.includes(ex.code)) shouldRetry = "network error";
if(this.maxRetries && ex && ex.response && this.retryStatusCodes.includes(ex.response.status)) shouldRetry = "server error";
if(!shouldRetry) throw ex;
requestLog.error(`[HttpUtils] Got ${shouldRetry} with ${shouldRetry === "network error" ? "code " + ex.code : "status " + ex.response.status} on ${opts.baseURL || this.baseURL || ""}${url}${retriesCount === 0 ? `. Reached max retries: ${this.maxRetries}` : ` Retrying ${shouldRetry}...`}`);
if(!(retriesCount > 0)) throw ex;

@@ -64,0 +68,0 @@ await this._delay();

{
"name": "@capriza/http-utils",
"version": "0.2.3",
"version": "0.2.4",
"description": "HTTP Request utils that handles, request-response, errors, concurrency, priority and authentication",

@@ -5,0 +5,0 @@ "main": "index.js",

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