backend: enhance recording start process sending FAILED event to client when an error occurs

This commit is contained in:
CSantosM 2026-02-04 15:20:12 +01:00
parent b08bb10f63
commit 59d722f882

View File

@ -85,6 +85,7 @@ export class RecordingService {
status: MeetRecordingStatus.STARTING
});
// Promise that rejects after timeout
const timeoutPromise = new Promise<never>((_, reject) => {
timeoutId = setTimeout(() => {
if (isOperationCompleted) return;
@ -98,6 +99,7 @@ export class RecordingService {
}, ms(INTERNAL_CONFIG.RECORDING_STARTED_TIMEOUT));
});
// Promise that resolves when RECORDING_ACTIVE event is received
const activeEgressEventPromise = new Promise<MeetRecordingInfo>((resolve) => {
eventListener = (info: Record<string, unknown>) => {
// Process the event only if it belongs to the current room.
@ -114,6 +116,7 @@ export class RecordingService {
this.systemEventService.on(DistributedEventType.RECORDING_ACTIVE, eventListener);
});
// Promise that starts the recording process
const startRecordingPromise = (async (): Promise<MeetRecordingInfo> => {
try {
const options = this.generateCompositeOptionsFromRequest(room.config, configOverride);
@ -144,6 +147,16 @@ export class RecordingService {
} catch (error) {
if (isOperationCompleted) {
this.logger.warn(`startRoomComposite failed after timeout: ${error}`);
// Manually send the recording FAILED signal to OpenVidu Components for avoiding missing event
await this.frontendEventService.sendRecordingSignalToOpenViduComponents(roomId, {
recordingId,
roomId,
roomName: roomId,
status: MeetRecordingStatus.FAILED,
error: (error as Error).message
});
throw errorRecordingStartTimeout(roomId);
}