Will retry on network error

master
j 2024-04-04 23:10:22 -04:00
parent 33577a7b24
commit 7c993cabaf
1 changed files with 9 additions and 1 deletions

View File

@ -88,8 +88,16 @@ class SessionManager {
}
private retryCondition(error: AxiosError): boolean {
// Check for network errors (e.g., socket hang up)
const isNetworkError = !error.response && Boolean(error.code); // No response and error.code is truthy indicates a network error
// Check for specific HTTP status codes
const status = error.response?.status ?? 0;
return status === 429 || status >= 500;
const isRateLimitError = status === 429;
const isServerError = status >= 500;
// Retry on network errors, rate limit errors, or server errors
return isNetworkError || isRateLimitError || isServerError;
}