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

@cortec/axios

Package Overview
Dependencies
Maintainers
0
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cortec/axios - npm Package Compare versions

Comparing version 2.3.6 to 2.4.0

3

dist/index.d.ts

@@ -19,3 +19,4 @@ import { type ITrace } from '@cortec/polka';

Notice4XX = 1,
InstrumentUrl = 2
InstrumentUrl = 2,
NoRetry = 4
}

@@ -22,0 +23,0 @@ export default class Axios implements IModule, IAxios {

@@ -36,2 +36,3 @@ "use strict";

const axios_1 = __importStar(require("axios"));
const exponential_backoff_1 = require("exponential-backoff");
const lodash_capitalize_1 = __importDefault(require("lodash.capitalize"));

@@ -43,2 +44,3 @@ var RequestFlags;

RequestFlags[RequestFlags["InstrumentUrl"] = 2] = "InstrumentUrl";
RequestFlags[RequestFlags["NoRetry"] = 4] = "NoRetry";
})(RequestFlags = exports.RequestFlags || (exports.RequestFlags = {}));

@@ -124,3 +126,20 @@ function match(trait, flag) {

}
return Reflect.get(target, prop, receiver)(...args).catch((err) => {
const instance = Reflect.get(target, prop, receiver);
// Execute the request and retry it if it fails
return (0, exponential_backoff_1.backOff)(() => instance(...args), {
numOfAttempts: 5,
startingDelay: 100,
retry: (err) => {
// If the request is marked as no retry, we should not retry
if (match(flags, RequestFlags.NoRetry))
return false;
// If the error is not an axios error, we should not retry
if (!(0, axios_1.isAxiosError)(err))
return false;
// Get the status code of the error and default to 0 if it's not present
const status = err.response?.status ?? 0;
// If the error is a server error, we should retry
return status >= 500;
},
}).catch((err) => {
// We are trying to figure-out of the external service is at fault

@@ -127,0 +146,0 @@ // So any non axios errors should be ignored and we throw back the original error

{
"name": "@cortec/axios",
"version": "2.3.6",
"version": "2.4.0",
"description": "<description>",

@@ -23,2 +23,3 @@ "main": "dist/index.js",

"@cortec/types": "1.15.0",
"exponential-backoff": "^3.1.2",
"lodash.capitalize": "^4.2.1"

@@ -42,3 +43,3 @@ },

},
"gitHead": "4766748db63351c578a88fcb90b694079d6cf42c"
"gitHead": "947916bdafd1bceb425e8374706e11497a60dd19"
}
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