From 0fc99445a27e496ad58a0a59bf5508adf8a60d47 Mon Sep 17 00:00:00 2001 From: Vellum Assistant Date: Mon, 23 Feb 2026 11:41:14 -0500 Subject: [PATCH] fix: clamp cleanup interval to setInterval-safe maximum Co-Authored-By: Claude --- assistant/src/config/schema.ts | 1 + assistant/src/daemon/recording-cleanup.ts | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/assistant/src/config/schema.ts b/assistant/src/config/schema.ts index 4c7156c6aa0..2577049f729 100644 --- a/assistant/src/config/schema.ts +++ b/assistant/src/config/schema.ts @@ -1064,6 +1064,7 @@ export const QaRecordingConfigSchema = z.object({ .number({ error: 'qaRecording.cleanupIntervalMs must be a number' }) .int('qaRecording.cleanupIntervalMs must be an integer') .positive('qaRecording.cleanupIntervalMs must be a positive integer') + .max(2_147_483_647, 'qaRecording.cleanupIntervalMs must be at most 2147483647 (setInterval-safe limit)') .default(6 * 60 * 60 * 1000), }); diff --git a/assistant/src/daemon/recording-cleanup.ts b/assistant/src/daemon/recording-cleanup.ts index 4b10323c674..5e8d0050528 100644 --- a/assistant/src/daemon/recording-cleanup.ts +++ b/assistant/src/daemon/recording-cleanup.ts @@ -75,13 +75,18 @@ export function startRecordingCleanup(intervalMs: number): void { log.warn({ err }, 'Initial recording cleanup pass failed'); } + // setInterval uses a 32-bit signed int internally; values above 2^31-1 ms + // (~24.8 days) wrap around and fire near-continuously. + const MAX_INTERVAL_MS = 2_147_483_647; + const safeInterval = Math.min(intervalMs, MAX_INTERVAL_MS); + cleanupTimer = setInterval(() => { try { runCleanupPass(); } catch (err) { log.warn({ err }, 'Periodic recording cleanup pass failed'); } - }, intervalMs); + }, safeInterval); // Don't keep the process alive just for cleanup cleanupTimer.unref();