Skip to content

Commit

Permalink
fix: Deprecate config.instance
Browse files Browse the repository at this point in the history
  • Loading branch information
orgads committed Dec 20, 2023
1 parent e888e95 commit 3a7f247
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface RetryConfig {

/**
* The instance of the axios object to which the interceptor is attached.
* @deprecated No longer needed.
*/
instance?: AxiosInstance;

Expand Down Expand Up @@ -179,7 +180,7 @@ async function onError(instance: AxiosInstance, error: AxiosError) {
config.retry = typeof config.retry === 'number' ? config.retry : 3;
config.retryDelay =
typeof config.retryDelay === 'number' ? config.retryDelay : 100;
config.instance = config.instance || instance;
instance = config.instance || instance;
config.backoffType = config.backoffType || 'exponential';
config.httpMethodsToRetry = normalizeArray(config.httpMethodsToRetry) || [
'GET',
Expand Down Expand Up @@ -296,7 +297,7 @@ async function onError(instance: AxiosInstance, error: AxiosError) {
return Promise.resolve()
.then(async () => onBackoffPromise)
.then(async () => onRetryAttemptPromise)
.then(async () => config.instance!.request(axiosError.config!));
.then(async () => instance.request(axiosError.config!));
}

/**
Expand Down
1 change: 0 additions & 1 deletion test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ describe('retry-axios', () => {
assert.strictEqual(config!.retry, 3, 'retry');
assert.strictEqual(config!.noResponseRetries, 2, 'noResponseRetries');
assert.strictEqual(config!.retryDelay, 100, 'retryDelay');
assert.strictEqual(config!.instance, axios, 'axios');
assert.strictEqual(config!.backoffType, 'exponential', 'backoffType');
assert.strictEqual(config!.checkRetryAfter, true);
assert.strictEqual(config!.maxRetryAfter, 60_000 * 5);
Expand Down

0 comments on commit 3a7f247

Please sign in to comment.