Skip to content

Commit

Permalink
feat: use exponential backoff delay by default
Browse files Browse the repository at this point in the history
Use exponential backoff delay by default

commit-id:e0f13cf2
  • Loading branch information
ttshivers committed Dec 23, 2023
1 parent 26a547e commit d5bdf16
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/http.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
};

Expand Down

0 comments on commit d5bdf16

Please sign in to comment.