feat: do not retry query range API's with i/o timeout error (#4768)

* feat: do not retry query range API's with i/o timeout error

* feat: do not retry query range API's with i/o timeout error
This commit is contained in:
Vikrant Gupta 2024-03-29 16:00:22 +05:30 committed by GitHub
parent 6eced60bf5
commit 43ceb052d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 3 deletions

View File

@ -30,7 +30,8 @@ export function ErrorResponseHandler(error: AxiosError): ErrorResponse {
statusCode, statusCode,
payload: null, payload: null,
error: errorMessage, error: errorMessage,
message: null, message: (response.data as any)?.status,
body: JSON.stringify((response.data as any).data),
}; };
} }

View File

@ -152,6 +152,16 @@ function GridCardGraph({
widget?.panelTypes, widget?.panelTypes,
widget.timePreferance, widget.timePreferance,
], ],
retry(failureCount, error): boolean {
if (
String(error).includes('status: error') &&
String(error).includes('i/o timeout')
) {
return false;
}
return failureCount < 2;
},
keepPreviousData: true, keepPreviousData: true,
enabled: queryEnabledCondition, enabled: queryEnabledCondition,
refetchOnMount: false, refetchOnMount: false,

View File

@ -34,7 +34,7 @@ export async function GetMetricQueryRange(
if (response.statusCode >= 400) { if (response.statusCode >= 400) {
throw new Error( throw new Error(
`API responded with ${response.statusCode} - ${response.error}`, `API responded with ${response.statusCode} - ${response.error} status: ${response.message}, errors: ${response?.body}`,
); );
} }

View File

@ -6,7 +6,8 @@ export interface ErrorResponse {
statusCode: ErrorStatusCode; statusCode: ErrorStatusCode;
payload: null; payload: null;
error: string; error: string;
message: null; message: string | null;
body?: string | null;
} }
export interface SuccessResponse<T, P = unknown> { export interface SuccessResponse<T, P = unknown> {