From 7e53a7bc2b36e20a05c9ef04bcc2709a641f4088 Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Tue, 28 Oct 2025 15:57:41 -0700 Subject: [PATCH] Server: tRPC: Retriers: carve0out 429 quota --- src/server/trpc/trpc.fetchers.retrier.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/server/trpc/trpc.fetchers.retrier.ts b/src/server/trpc/trpc.fetchers.retrier.ts index ad734c441..6198488a1 100644 --- a/src/server/trpc/trpc.fetchers.retrier.ts +++ b/src/server/trpc/trpc.fetchers.retrier.ts @@ -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;