Avoid mute timeouts with invalid delay values

Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
automated-signal
2025-02-03 15:10:01 -06:00
committed by GitHub
parent 9f5115a537
commit 4e9d7321b6
2 changed files with 10 additions and 1 deletions

View File

@@ -210,6 +210,8 @@ export function formatDate(
export const MAX_SAFE_DATE = 8640000000000000;
export const MIN_SAFE_DATE = -8640000000000000;
export const MAX_SAFE_TIMEOUT_DELAY = 2147483647; // max 32-bit signed integer
export function toBoundedDate(timestamp: number): Date {
return new Date(Math.max(MIN_SAFE_DATE, Math.min(timestamp, MAX_SAFE_DATE)));
}