From d5bdf16c675e72bfd59ac5aa5e6e8d535e3bad73 Mon Sep 17 00:00:00 2001 From: Conicaw Date: Sat, 23 Dec 2023 17:59:25 -0600 Subject: [PATCH] feat: use exponential backoff delay by default Use exponential backoff delay by default commit-id:e0f13cf2 --- lib/http.module.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/http.module.ts b/lib/http.module.ts index 2573776..a9ab1be 100644 --- a/lib/http.module.ts +++ b/lib/http.module.ts @@ -2,7 +2,7 @@ import type { DynamicModule, Provider } from '@nestjs/common'; import { Module } from '@nestjs/common'; import { randomStringGenerator } from '@nestjs/common/utils/random-string-generator.util'; import axios from 'axios'; -import axiosRetry from 'axios-retry'; +import axiosRetry, { exponentialDelay } from 'axios-retry'; import { AXIOS_INSTANCE_TOKEN, HTTP_MODULE_ID, HTTP_MODULE_OPTIONS } from './http.constants'; import { HttpService } from './http.service'; @@ -14,7 +14,11 @@ import type { const createAxiosInstance = (config?: HttpModuleOptions) => { const axiosInstance = axios.create(config); - axiosRetry(axiosInstance, config); + axiosRetry(axiosInstance, { + // Default exponential backoff + retryDelay: exponentialDelay, + ...config, + }); return axiosInstance; };