Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions assistant/src/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
});

Expand Down
7 changes: 6 additions & 1 deletion assistant/src/daemon/recording-cleanup.ts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Log message reports original intervalMs instead of clamped safeInterval

When startRecordingCleanup is called with an intervalMs value exceeding 2^31-1, the runtime clamp on line 81 correctly limits the actual interval passed to setInterval. However, the log message on line 93 still reports the original unclamped intervalMs value, misleading operators into thinking the timer is running at the requested (overflowing) interval.

Detailed Explanation

On line 81, safeInterval is computed as Math.min(intervalMs, MAX_INTERVAL_MS), and this clamped value is correctly passed to setInterval on line 89. But the log on line 93 logs { intervalMs } — the original parameter — not the actual value used:

log.info({ intervalMs }, 'Recording cleanup worker started');

If clamping occurs, the log would say e.g. intervalMs: 3000000000 while the real interval is 2147483647. This makes debugging timer behavior harder.

In practice, the schema validation (.max(2_147_483_647) at assistant/src/config/schema.ts:1067) prevents out-of-range values from reaching this code path via config, so this only affects direct callers bypassing config validation.

Impact: Misleading log output when clamping is triggered; low practical impact given schema validation.

(Refers to line 93)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading