Skip to content

Commit

Permalink
chore: improve error cache plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
suhaotian committed Feb 24, 2024
1 parent c5d92d8 commit 5551a0a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/plugins/error-retry.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sleep } from './utils';
import { delay } from './utils';
import { XiorPlugin } from '../types';
import { XiorError, XiorTimeoutError } from '../utils';

Expand All @@ -7,7 +7,7 @@ export type ErrorRetryOptions = {
retryTimes?: number;
/**
* Retry after milliseconds, default: 3000
* after first time error retry have interval
* after first time error retry, retry interval
*/
retryInterval?: number;
/**
Expand Down Expand Up @@ -52,7 +52,7 @@ export default function xiorErrorRetryPlugin(options: ErrorRetryOptions = {}): X
}

if (retryInterval && retryInterval > 0 && count > 0) {
await sleep(retryInterval);
await delay(retryInterval);
}

count++;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export function sleep(ms: number) {
export function delay(ms: number) {
return new Promise((resolve) => {
setTimeout(() => {
resolve('ok');
Expand Down

0 comments on commit 5551a0a

Please sign in to comment.