feat: add some extra retry functions

Add some extra retry functions

commit-id:7b1d5b99
This commit is contained in:
Conicaw 2023-12-23 18:31:33 -06:00
parent 99cb1c6216
commit 56cef0dff7
No known key found for this signature in database
GPG key ID: 8DE10AC00159C418

10
lib/http.util.ts Normal file
View file

@ -0,0 +1,10 @@
import type { AxiosError } from 'axios';
import { isNetworkOrIdempotentRequestError } from 'axios-retry';
export function isGatewayError(error: AxiosError): boolean {
return !!error.response && error.response.status >= 502 && error.response.status <= 504;
}
export function isNetworkOrIdempotentRequestOrGatewayError(error: AxiosError): boolean {
return isNetworkOrIdempotentRequestError(error) || isGatewayError(error);
}