diff --git a/backend/src/config/internal-config.ts b/backend/src/config/internal-config.ts index 6a841a1..6129ed4 100644 --- a/backend/src/config/internal-config.ts +++ b/backend/src/config/internal-config.ts @@ -36,7 +36,7 @@ const INTERNAL_CONFIG = { // This function is used to set private configuration values for testing purposes. // It allows you to override the default values defined in the INTERNAL_CONFIG object. // This is useful for testing different scenarios without modifying the actual configuration file. -export const setPrivateConfig = (overrides: Partial): void => { +export const setInternalConfig = (overrides: Partial): void => { Object.assign(INTERNAL_CONFIG, overrides); }; diff --git a/backend/src/models/error.model.ts b/backend/src/models/error.model.ts index e4ee649..99b39d2 100644 --- a/backend/src/models/error.model.ts +++ b/backend/src/models/error.model.ts @@ -75,6 +75,14 @@ export const errorRecordingAlreadyStarted = (roomId: string): OpenViduMeetError return new OpenViduMeetError('Recording Error', `The room '${roomId}' is already being recorded`, 409); }; +export const errorRecordingStartTimeout = (roomId: string): OpenViduMeetError => { + return new OpenViduMeetError( + 'Recording Error', + `Recording in room '${roomId}' timed out while starting`, + 503 + ); +}; + export const errorRoomHasNoParticipants = (roomId: string): OpenViduMeetError => { return new OpenViduMeetError('Recording Error', `The room '${roomId}' has no participants`, 409); }; diff --git a/backend/src/services/livekit-webhook.service.ts b/backend/src/services/livekit-webhook.service.ts index d9113d3..10d3946 100644 --- a/backend/src/services/livekit-webhook.service.ts +++ b/backend/src/services/livekit-webhook.service.ts @@ -207,10 +207,10 @@ export class LivekitWebhookService { if (recordingInfo.status === MeetRecordingStatus.ACTIVE) { // Send system event for active recording with the aim of cancelling the cleanup timer tasks.push( - this.systemEventService.publishEvent(SystemEventType.RECORDING_ACTIVE, { - roomId, - recordingId - }) + this.systemEventService.publishEvent( + SystemEventType.RECORDING_ACTIVE, + recordingInfo as unknown as Record + ) ); } diff --git a/backend/src/services/recording.service.ts b/backend/src/services/recording.service.ts index 9d47639..f4a478e 100644 --- a/backend/src/services/recording.service.ts +++ b/backend/src/services/recording.service.ts @@ -9,6 +9,7 @@ import { errorRecordingCannotBeStoppedWhileStarting, errorRecordingNotFound, errorRecordingNotStopped, + errorRecordingStartTimeout, errorRoomHasNoParticipants, errorRoomNotFound, internalError, @@ -21,10 +22,7 @@ import { S3Service } from './s3.service.js'; import { LoggerService } from './logger.service.js'; import { MeetRecordingFilters, MeetRecordingInfo, MeetRecordingStatus } from '@typings-ce'; import { RecordingHelper } from '../helpers/recording.helper.js'; -import { - MEET_S3_BUCKET, - MEET_S3_SUBBUCKET -} from '../environment.js'; +import { MEET_S3_BUCKET, MEET_S3_SUBBUCKET } from '../environment.js'; import { RoomService } from './room.service.js'; import { inject, injectable } from '../config/dependency-injector.config.js'; import { MutexService, RedisLock } from './mutex.service.js'; @@ -94,17 +92,16 @@ export class RecordingService { callback: this.handleRecordingLockTimeout.bind(this, recordingId, roomId, reject) }); - this.systemEventService.once(SystemEventType.RECORDING_ACTIVE, (payload: Record) => { + this.systemEventService.once(SystemEventType.RECORDING_ACTIVE, (info: Record) => { // This listener is triggered only for the instance that started the recording. // Check if the recording ID matches the one that was started - const isEventForCurrentRecording = - payload?.recordingId === recordingId && payload?.roomId === roomId; + const isEventForCurrentRecording = info?.recordingId === recordingId && info?.roomId === roomId; if (isEventForCurrentRecording) { this.taskSchedulerService.cancelTask(`${roomId}_recording_timeout`); - resolve(recordingInfo); + resolve(info as unknown as MeetRecordingInfo); } else { - this.logger.error('Received recording active event with mismatched recording ID:', payload); + this.logger.error('Received recording active event with mismatched recording ID:', info); } }); }); @@ -528,9 +525,7 @@ export class RecordingService { } // Reject the REST request with a timeout error. - rejectRequest( - new Error(`Timeout waiting for '${SystemEventType.RECORDING_ACTIVE}' event in room '${roomId}'`) - ); + rejectRequest(errorRecordingStartTimeout(roomId)); } }