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

@aircall/http

Package Overview
Dependencies
Maintainers
5
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aircall/http - npm Package Compare versions

Comparing version 0.5.8 to 0.6.0

6

CHANGELOG.md

@@ -6,2 +6,8 @@ # Change Log

# [0.6.0](https://gitlab.com/aircall/shared/front-end-modules/compare/@aircall/http@0.5.8...@aircall/http@0.6.0) (2023-01-05)
### Features
- **http:** add exponential backoff [PH-8020] ([392a339](https://gitlab.com/aircall/shared/front-end-modules/commit/392a339f7167f47c1cc2d97c00fcc08ce74c5093))
## [0.5.8](https://gitlab.com/aircall/shared/front-end-modules/compare/@aircall/http@0.5.7...@aircall/http@0.5.8) (2022-11-23)

@@ -8,0 +14,0 @@

11

dist/HttpService.js

@@ -76,6 +76,8 @@ "use strict";

const shouldRetry = retryCondition(error) && config.retryCount < maxRetry;
const isDelayFunction = typeof delay === 'function';
const delayDuration = isDelayFunction ? delay(config.retryCount) : delay;
if (shouldRetry) {
config.retryCount++;
if (delay > 0) {
await (0, utils_1.sleep)(delay);
if (delayDuration > 0) {
await (0, utils_1.sleep)(delayDuration);
}

@@ -108,4 +110,4 @@ await onRetryAttempt(error);

this.axiosInstance.interceptors.request.use(this.logRequestInterceptor);
this.axiosInstance.interceptors.response.use(undefined, this.retryStrategyInterceptor);
this.axiosInstance.interceptors.response.use(this.logResponseInterceptor, this.logErrorInterceptor);
this.axiosInstance.interceptors.response.use(undefined, this.retryStrategyInterceptor);
if (handleError) {

@@ -160,3 +162,4 @@ this.axiosInstance.interceptors.response.use(undefined, handleError);

request_params: config.params,
request_path: config.url
request_path: config.url,
retry_count: config.retryCount
};

@@ -163,0 +166,0 @@ };

@@ -15,2 +15,3 @@ import { AxiosRequestConfig, AxiosError, AxiosPromise } from 'axios';

request_path: AxiosRequestConfig['url'];
retry_count: AxiosRequestConfig['retryCount'];
}

@@ -32,3 +33,3 @@ export interface ErrorLogPayload {

onRetryAttempt?: <T extends HttpError>(error: T) => Promise<any>;
delay?: number;
delay?: number | ((countRetry: number) => number);
}

@@ -35,0 +36,0 @@ export declare type HTTP_LOG_TYPE = 'REQUEST' | 'SUCCESS' | 'ERROR';

{
"name": "@aircall/http",
"version": "0.5.8",
"version": "0.6.0",
"main": "dist/index.js",

@@ -14,5 +14,5 @@ "types": "dist/index.d.ts",

},
"gitHead": "7eac698c52c31b47c1e674586e174e3936373e73",
"gitHead": "f56e14dde828c80b6d68afaa1f56972a669249a6",
"dependencies": {
"@aircall/logger": "^2.8.1",
"@aircall/logger": "^2.8.2",
"axios": "^0.27.2"

@@ -19,0 +19,0 @@ },

@@ -26,2 +26,3 @@ import axios, { AxiosInstance, AxiosRequestConfig, AxiosError, AxiosResponse } from 'axios';

}
class HttpService {

@@ -62,2 +63,3 @@ private token?: string;

this.axiosInstance.interceptors.request.use(this.logRequestInterceptor);
this.axiosInstance.interceptors.response.use(undefined, this.retryStrategyInterceptor);
this.axiosInstance.interceptors.response.use(

@@ -68,4 +70,2 @@ this.logResponseInterceptor,

this.axiosInstance.interceptors.response.use(undefined, this.retryStrategyInterceptor);
if (handleError) {

@@ -138,3 +138,4 @@ this.axiosInstance.interceptors.response.use(undefined, handleError);

request_params: config.params,
request_path: config.url
request_path: config.url,
retry_count: config.retryCount
};

@@ -215,8 +216,12 @@ };

config.retryCount = config.retryCount ?? 0;
const shouldRetry = retryCondition(error) && config.retryCount < maxRetry;
const isDelayFunction = typeof delay === 'function';
const delayDuration = isDelayFunction ? delay(config.retryCount) : delay;
if (shouldRetry) {
config.retryCount++;
if (delay > 0) {
await sleep(delay);
if (delayDuration > 0) {
await sleep(delayDuration);
}

@@ -223,0 +228,0 @@

@@ -16,2 +16,3 @@ import { AxiosRequestConfig, AxiosError, AxiosPromise } from 'axios';

request_path: AxiosRequestConfig['url'];
retry_count: AxiosRequestConfig['retryCount'];
}

@@ -38,3 +39,3 @@

// Zero means that no delay will be applied
delay?: number;
delay?: number | ((countRetry: number) => number);
}

@@ -41,0 +42,0 @@

Sorry, the diff of this file is not supported yet

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