gg
Deploy Iddaai Backend / build-and-deploy (push) Successful in 2m45s

This commit is contained in:
2026-05-05 14:06:20 +03:00
parent 7a1cf14e2f
commit 9bb8f39bca
8 changed files with 404 additions and 157 deletions
+18 -1
View File
@@ -134,7 +134,13 @@ export class AiEngineClient {
const shouldRetry = attempt < retries && this.isRetriableError(error);
if (!shouldRetry) {
this.registerFailure(error);
// Only register circuit breaker failure for server/network errors, not client errors (4xx)
if (this.isServerError(error)) {
this.registerFailure(error);
} else {
// It's a successful contact with the engine (e.g. 404, 422), so reset failures
this.resetFailures();
}
throw this.toRequestError(error);
}
@@ -220,6 +226,17 @@ export class AiEngineClient {
return status >= 500 || status === 429 || error.code === "ECONNABORTED";
}
private isServerError(error: unknown): boolean {
if (!axios.isAxiosError(error)) {
return true; // Not an axios error, assume internal/network error
}
if (!error.response) {
return true; // Network error, timeout, etc.
}
const status = error.response.status;
return status >= 500 || status === 429;
}
private toRequestError(error: unknown): AiEngineRequestError {
if (error instanceof AiEngineRequestError) {
return error;