backend: improve documentation for stale recording evaluation logic

This commit is contained in:
Carlos Santos 2025-11-13 10:50:22 +01:00
parent f3de3e0fa3
commit 26bc6cdfc1
2 changed files with 9 additions and 6 deletions

View File

@ -47,7 +47,7 @@ export const INTERNAL_CONFIG = {
RECORDING_STARTED_TIMEOUT: '20s' as StringValue, // Timeout for recording start
RECORDING_LOCK_GC_INTERVAL: '30m' as StringValue, // Garbage collection interval for recording locks
RECORDING_ORPHANED_LOCK_GRACE_PERIOD: '1m' as StringValue, // Grace period for orphaned recording locks
RECORDING_STALE_CLEANUP_INTERVAL: '15m' as StringValue, // Cleanup interval for stale recordings
RECORDING_STALE_CLEANUP_INTERVAL: '15m' as StringValue, // Interval for cleaning up stale recordings that have not been updated within the allowed time
RECORDING_STALE_AFTER: '5m' as StringValue, // Maximum allowed time since the last recording update before marking as stale
CRON_JOB_MIN_LOCK_TTL: '59s' as StringValue, // Minimum TTL for cron job locks

View File

@ -962,11 +962,15 @@ export class RecordingService {
}
/**
* Evaluates a single recording and aborts it if it's considered stale.
* Evaluates whether a recording is stale and aborts it if necessary.
* A recording is considered stale if it has not been updated within the configured stale period
* and either the associated LiveKit room does not exist or has no publishers.
* If the recording is already aborted or has no updatedAt timestamp, it is kept as fresh.
*
* @param egressInfo - The egress information for the recording to evaluate
* @returns {Promise<boolean>} True if the recording was aborted, false if it's still fresh
* @protected
* @param egressInfo - The egress information containing details about the recording.
* @returns A promise that resolves to `true` if the recording was aborted, `false` otherwise.
* @throws Will throw an error if there is an issue retrieving recording status, checking room existence,
* or aborting the recording.
*/
protected async evaluateAndAbortStaleRecording(egressInfo: EgressInfo): Promise<boolean> {
const recordingId = RecordingHelper.extractRecordingIdFromEgress(egressInfo);
@ -1001,7 +1005,6 @@ export class RecordingService {
}
// Check if recording has not been updated recently
this.logger.debug(`Recording ${recordingId} last updated at ${new Date(updatedAt).toISOString()}`);
if (!isRecordingStale) {