From 3bdbc79bf0458e528edae45b1cd72364c1612864 Mon Sep 17 00:00:00 2001 From: Pavan Kumar VH Date: Thu, 3 Sep 2026 15:32:03 +0530 Subject: [PATCH] Fix Infinity validation in daysBetween The function only checked for NaN, not Infinity. If the date string represented an extreme date, getTime() could return Infinity, causing Math.round(Infinity) to return Infinity. Changed Number.isNaN() to Number.isFinite() to catch both NaN and Infinity. --- common/src/util/reddit-freebuff-retention.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/util/reddit-freebuff-retention.ts b/common/src/util/reddit-freebuff-retention.ts index 2c1e698b51..2c909593b2 100644 --- a/common/src/util/reddit-freebuff-retention.ts +++ b/common/src/util/reddit-freebuff-retention.ts @@ -14,7 +14,7 @@ export type FreebuffRedditConversionPlan = { function daysBetween(fromDateKey: string, toDateKey: string): number { const from = new Date(`${fromDateKey}T00:00:00.000Z`).getTime() const to = new Date(`${toDateKey}T00:00:00.000Z`).getTime() - if (Number.isNaN(from) || Number.isNaN(to)) { + if (!Number.isFinite(from) || !Number.isFinite(to)) { throw new Error(`Invalid date key range: ${fromDateKey} -> ${toDateKey}`) } return Math.round((to - from) / DAY_MS)