Fix NaN handling in build seconds calculation - #1245
Conversation
The code didn't validate that buildSeconds is a finite number. If buildSeconds was NaN or Infinity, Math.round(NaN / 60) would return NaN. Added Number.isFinite() check to default to 0 for invalid numbers.
|
Thanks for digging into There is a real (if narrow) edge case your fix does catch: if Could you:
The change itself is small, safe, and in-scope for |
Overview
Fix NaN handling in build seconds calculation in
common/src/util/db-health-alerts.ts.Bug Description
The code didn't validate that buildSeconds is a finite number. If buildSeconds was NaN or Infinity,
Math.round(NaN / 60)would return NaN.Fix
Added
Number.isFinite()check to default to 0 for invalid numbers.Testing
No existing tests for this function, but the fix prevents incorrect behavior with invalid inputs.
Files Changed
common/src/util/db-health-alerts.ts- Added NaN validationScope
This change only touches
common/which is an approved contribution area per the Contributing Guide.