Description
In utils/dateRange.ts, the fallback range was an exported constant whose year was evaluated once, when the module is first loaded:
export const DEFAULT_DATE_RANGE = {
from: `${new Date().getUTCFullYear()}-01-01T00:00:00Z`,
to: `${new Date().getUTCFullYear()}-12-31T23:59:59Z`,
};
Because new Date().getUTCFullYear() runs at module-load time, the value becomes stale once the process crosses a New Year boundary. A long-lived process that loaded the module in December would keep returning the previous year's range in January. formatDateRange returns this same value for missing or invalid years, so its fallback inherits the staleness.
DEFAULT_DATE_RANGE and formatDateRange currently have no production callers (only the module itself and its test reference them), so the present impact is limited to tests, but the value is incorrect by construction.
Steps to Reproduce
- Load
utils/dateRange.ts in a process during December of year N.
- Keep the process alive past midnight UTC on January 1 of year N+1.
- Read
DEFAULT_DATE_RANGE (or call formatDateRange('')).
- Observe the range still reports year N rather than N+1.
Expected Behavior
The default range reflects the current year whenever it is read, so it stays correct after a New Year rollover.
Screenshots / Logs
Not applicable.
Environment
Other
Description
In
utils/dateRange.ts, the fallback range was an exported constant whose year was evaluated once, when the module is first loaded:Because
new Date().getUTCFullYear()runs at module-load time, the value becomes stale once the process crosses a New Year boundary. A long-lived process that loaded the module in December would keep returning the previous year's range in January.formatDateRangereturns this same value for missing or invalid years, so its fallback inherits the staleness.DEFAULT_DATE_RANGEandformatDateRangecurrently have no production callers (only the module itself and its test reference them), so the present impact is limited to tests, but the value is incorrect by construction.Steps to Reproduce
utils/dateRange.tsin a process during December of year N.DEFAULT_DATE_RANGE(or callformatDateRange('')).Expected Behavior
The default range reflects the current year whenever it is read, so it stays correct after a New Year rollover.
Screenshots / Logs
Not applicable.
Environment
Other