Server: tRPC: Retriers: carve0out 429 quota

This commit is contained in:
Enrico Ros
2025-10-28 15:57:41 -07:00
parent 4df10e3782
commit 7e53a7bc2b
+13 -2
View File
@@ -35,10 +35,21 @@ function selectRetryProfile(error: TRPCFetcherError | unknown): RetryProfile | n
return RETRY_PROFILES.network; // DNS, TCP, timeouts, ... doesn't connect
if (error.category === 'http' && error.httpStatus) {
// 429 Too Many Requests: distinguish quota errors (don't retry) from rate limits (retry)
if (error.httpStatus === 429) {
const isQuotaError = /quota|billing/i.test(error.message);
if (isQuotaError) {
if (AIX_DEBUG_SERVER_RETRY)
console.log(`[fetchers.retrier] Detected quota/billing error - will not retry`);
return null; // Don't retry quota/billing errors - user needs to upgrade plan
}
return RETRY_PROFILES.server; // Retry temporary rate limits
}
// retriable server errors
const retryCodes = [
429, // Too Many Requests
503, // Service Unavailable <- main one to retry
502, // Bad Gateway
503, // Service Unavailable
];
if (retryCodes.includes(error.httpStatus))
return RETRY_PROFILES.server;