fix: track monthly usage for unlimited quotas (#2894)

This commit is contained in:
David Nguyen
2026-05-31 13:34:10 +10:00
committed by GitHub
parent 61138cdd81
commit 44c4826e92
3 changed files with 41 additions and 26 deletions
@@ -19,10 +19,6 @@ const COUNTER_COLUMN = {
} as const satisfies Record<LimitCounter, string>;
export const checkMonthlyQuota = async (opts: CheckMonthlyQuotaOptions): Promise<void> => {
if (opts.quota === null) {
return;
}
if (opts.quota === 0) {
throw new AppError(AppErrorCode.TOO_MANY_REQUESTS, {
message:
@@ -52,6 +48,11 @@ export const checkMonthlyQuota = async (opts: CheckMonthlyQuotaOptions): Promise
},
});
// For unlimited quotas, we still allow the request to send so we can collect the monthly stat.
if (opts.quota === null) {
return;
}
const newCount = latestMonthlyStat[column];
const previousCount = newCount - opts.count;