fix(quota): ignore invalid reset timestamps (#1182)

* fix(quota): ignore invalid reset timestamps

* fix(quota): guard reset-after timestamps

---------

Co-authored-by: Isaac Sanchez <isanchez-hawkins@arize.com>
This commit is contained in:
Isaac Sanchez-Hawkins
2026-05-12 11:05:22 +03:00
committed by GitHub
co-authored by Isaac Sanchez
parent 323347f50e
commit b944bd812c
2 changed files with 28 additions and 1 deletions
@@ -1,6 +1,10 @@
export const formatResetTime = (timestamp) => {
try {
const resetDate = new Date(timestamp);
if (!Number.isFinite(resetDate.getTime())) {
return null;
}
const now = new Date();
const isToday = resetDate.toDateString() === now.toDateString();
@@ -25,7 +29,9 @@ export const formatResetTime = (timestamp) => {
export const calculateResetAfterSeconds = (resetAt) => {
if (!resetAt) return null;
const delta = Math.floor((resetAt - Date.now()) / 1000);
const resetAtTime = new Date(resetAt).getTime();
if (!Number.isFinite(resetAtTime)) return null;
const delta = Math.floor((resetAtTime - Date.now()) / 1000);
return delta < 0 ? 0 : delta;
};