From 56cef0dff75d6cde7b650a9d47a92b3fcc1ee4c0 Mon Sep 17 00:00:00 2001 From: Conicaw Date: Sat, 23 Dec 2023 18:31:33 -0600 Subject: [PATCH] feat: add some extra retry functions Add some extra retry functions commit-id:7b1d5b99 --- lib/http.util.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 lib/http.util.ts diff --git a/lib/http.util.ts b/lib/http.util.ts new file mode 100644 index 0000000..77b0cf8 --- /dev/null +++ b/lib/http.util.ts @@ -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); +}