feat: add retry on random failure
This commit is contained in:
parent
0ac7d52799
commit
b2769eed2f
|
|
@ -23,7 +23,8 @@ export abstract class SocialAbstract {
|
|||
async fetch(
|
||||
url: string,
|
||||
options: RequestInit = {},
|
||||
identifier = ''
|
||||
identifier = '',
|
||||
totalRetries = 0
|
||||
): Promise<Response> {
|
||||
const request = await fetch(url, options);
|
||||
|
||||
|
|
@ -55,6 +56,11 @@ export abstract class SocialAbstract {
|
|||
throw new RefreshToken(identifier, json, options.body!);
|
||||
}
|
||||
|
||||
if (totalRetries < 2) {
|
||||
await timer(2000);
|
||||
return this.fetch(url, options, identifier, totalRetries + 1);
|
||||
}
|
||||
|
||||
throw new BadBody(identifier, json, options.body!);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue