This commit is contained in:
Iliyan Angelov
2025-11-21 22:40:44 +02:00
parent 9842cc3a4a
commit be07802066
60 changed files with 8189 additions and 9 deletions

View File

@@ -9,7 +9,9 @@ const API_BASE_URL = /\/api(\/?$)/i.test(normalized)
const MAX_RETRIES = 3;
const RETRY_DELAY = 1000;
const RETRYABLE_STATUS_CODES = [408, 429, 500, 502, 503, 504];
// Note: 503 is excluded because it's used for "service unavailable" (like disabled features)
// and should not be retried - it's an intentional state, not a transient error
const RETRYABLE_STATUS_CODES = [408, 429, 500, 502, 504];
const apiClient = axios.create({
baseURL: API_BASE_URL,
@@ -187,6 +189,19 @@ apiClient.interceptors.response.use(
}
// Handle 503 (Service Unavailable) separately - often used for disabled features
// Don't retry these as they're intentional states, not transient errors
if (status === 503) {
const errorData = error.response.data as any;
const errorMessage = errorData?.detail || errorData?.message || 'Service temporarily unavailable';
return Promise.reject({
...error,
message: errorMessage,
requestId,
});
}
if (status >= 500 && status < 600) {
if (originalRequest && !originalRequest._retry) {
return retryRequest(error);