diff --git a/apps/meteor/server/services/media-call/service.ts b/apps/meteor/server/services/media-call/service.ts index b52476c272196..009e494516b95 100644 --- a/apps/meteor/server/services/media-call/service.ts +++ b/apps/meteor/server/services/media-call/service.ts @@ -43,8 +43,8 @@ export class MediaCallService extends ServiceClassInternal implements IMediaCall try { logger.debug({ msg: 'new client signal', type: signal.type, uid }); callServer.receiveSignal(uid, signal); - } catch (error) { - logger.error({ msg: 'failed to process client signal', error, signal, uid }); + } catch (err) { + logger.error({ msg: 'failed to process client signal', err, signal, uid }); } } @@ -55,22 +55,22 @@ export class MediaCallService extends ServiceClassInternal implements IMediaCall const deserialized = await this.deserializeClientSignal(signal); callServer.receiveSignal(uid, deserialized); - } catch (error) { - logger.error({ msg: 'failed to process client signal', error, uid }); + } catch (err) { + logger.error({ msg: 'failed to process client signal', err, uid }); } } public async hangupExpiredCalls(): Promise { - await callServer.hangupExpiredCalls().catch((error) => { - logger.error({ msg: 'Media Call Server failed to hangup expired calls', error }); + await callServer.hangupExpiredCalls().catch((err) => { + logger.error({ msg: 'Media Call Server failed to hangup expired calls', err }); }); try { if (await MediaCalls.hasUnfinishedCalls()) { callServer.scheduleExpirationCheck(); } - } catch (error) { - logger.error({ msg: 'Media Call Server failed to check if there are expired calls', error }); + } catch (err) { + logger.error({ msg: 'Media Call Server failed to check if there are expired calls', err }); } } @@ -129,9 +129,7 @@ export class MediaCallService extends ServiceClassInternal implements IMediaCall contactExtension, }; - await CallHistory.insertOne(historyItem).catch((error: unknown) => - logger.error({ msg: 'Failed to insert item into Call History', error }), - ); + await CallHistory.insertOne(historyItem).catch((err: unknown) => logger.error({ msg: 'Failed to insert item into Call History', err })); } private async saveInternalCallToHistory(call: IMediaCall): Promise { @@ -140,8 +138,8 @@ export class MediaCallService extends ServiceClassInternal implements IMediaCall return; } - const room = await this.getRoomIdForInternalCall(call).catch((error) => { - logger.error({ msg: 'Failed to determine room id for Internal Call', error }); + const room = await this.getRoomIdForInternalCall(call).catch((err) => { + logger.error({ msg: 'Failed to determine room id for Internal Call', err }); return undefined; }); const { _id: rid } = room || {}; @@ -173,8 +171,8 @@ export class MediaCallService extends ServiceClassInternal implements IMediaCall contactId: call.caller.id, } as const; - await CallHistory.insertMany([outboundHistoryItem, inboundHistoryItem]).catch((error: unknown) => - logger.error({ msg: 'Failed to insert items into Call History', error }), + await CallHistory.insertMany([outboundHistoryItem, inboundHistoryItem]).catch((err: unknown) => + logger.error({ msg: 'Failed to insert items into Call History', err }), ); if (room) { @@ -203,9 +201,8 @@ export class MediaCallService extends ServiceClassInternal implements IMediaCall return; } throw new Error('Failed to save message id in history'); - } catch (error) { - const errorMessage = error instanceof Error ? error.message : 'Failed to send history message'; - logger.error({ msg: errorMessage, error, callId: call._id }); + } catch (err) { + logger.error({ msg: 'Failed to send history message', err, callId: call._id }); } } @@ -325,9 +322,9 @@ export class MediaCallService extends ServiceClassInternal implements IMediaCall throw new Error('signal-format-invalid'); } return signal; - } catch (error) { - logger.error({ msg: 'Failed to parse client signal' }, error); - throw error; + } catch (err) { + logger.error({ msg: 'Failed to parse client signal', err }); + throw err; } } } diff --git a/ee/packages/media-calls/src/server/CallDirector.ts b/ee/packages/media-calls/src/server/CallDirector.ts index 4ed1cb60eff74..2c1203f1faa80 100644 --- a/ee/packages/media-calls/src/server/CallDirector.ts +++ b/ee/packages/media-calls/src/server/CallDirector.ts @@ -116,9 +116,9 @@ class MediaCallDirector { public get cast(): IMediaCallCastDirector { try { return getCastDirector(); - } catch (error) { - logger.error({ msg: 'Failed to access castDirector', error }); - throw error; + } catch (err) { + logger.error({ msg: 'Failed to access castDirector', err }); + throw err; } } @@ -303,8 +303,8 @@ class MediaCallDirector { logger.debug({ msg: 'MediaCallDirector.scheduleExpirationCheckByCallId.timeout', callId }); scheduledExpirationChecks.delete(callId); - const expectedCallWasExpired = await this.hangupExpiredCalls(callId).catch((error) => - logger.error({ msg: 'Media Call Monitor failed to hangup expired calls', error }), + const expectedCallWasExpired = await this.hangupExpiredCalls(callId).catch((err) => + logger.error({ msg: 'Media Call Monitor failed to hangup expired calls', err }), ); if (!expectedCallWasExpired) { @@ -321,19 +321,19 @@ class MediaCallDirector { public scheduleExpirationCheck(): void { setTimeout(async () => { logger.debug({ msg: 'MediaCallDirector.scheduleExpirationCheck.timeout' }); - await this.hangupExpiredCalls().catch((error) => logger.error({ msg: 'Media Call Monitor failed to hangup expired calls', error })); + await this.hangupExpiredCalls().catch((err) => logger.error({ msg: 'Media Call Monitor failed to hangup expired calls', err })); }, EXPIRATION_CHECK_TIMEOUT); } public async runOnCallCreatedForAgent(call: IMediaCall, agent: IMediaCallAgent, agentToNotifyIfItFails?: IMediaCallAgent): Promise { try { await agent.onCallCreated(call); - } catch (error) { + } catch (err) { // If the agent failed, we assume they cleaned up after themselves and just hangup the call // We then notify the other agent that the call has ended, but only if it the agent was already notified about this call in the first place logger.error({ msg: 'Agent failed to process a new call.', - error, + err, agentRole: agent.role, callerType: call.caller.type, calleeType: call.callee.type, @@ -342,7 +342,7 @@ class MediaCallDirector { endedBy: agent.getMyCallActor(call), reason: 'error', }); - throw error; + throw err; } } @@ -358,15 +358,15 @@ class MediaCallDirector { ...(endedBy && { endedBy }), }; - const result = await MediaCalls.hangupCallById(callId, cleanedParams).catch((error) => { + const result = await MediaCalls.hangupCallById(callId, cleanedParams).catch((err) => { logger.error({ msg: 'Failed to hangup a call.', callId, - hangupError: error, + err, hangupReason: params?.reason, hangupActor: params?.endedBy, }); - throw error; + throw err; }); const ended = Boolean(result.modifiedCount); @@ -389,7 +389,7 @@ class MediaCallDirector { await Promise.allSettled( agents.map(async (agent) => - agent.onCallEnded(callId).catch((error) => logger.error({ msg: 'Failed to notify agent of a hangup', error, actor: agent.actor })), + agent.onCallEnded(callId).catch((err) => logger.error({ msg: 'Failed to notify agent of a hangup', err, actor: agent.actor })), ), ); } @@ -413,8 +413,8 @@ class MediaCallDirector { } catch { // Ignore errors on the ended event } - } catch (error) { - logger.error({ msg: 'Failed to terminate call.', error, callId: call._id, params }); + } catch (err) { + logger.error({ msg: 'Failed to terminate call.', err, callId: call._id, params }); } } } diff --git a/ee/packages/media-calls/src/server/MediaCallServer.ts b/ee/packages/media-calls/src/server/MediaCallServer.ts index 2065b05ec04b8..a4f2ac88cbcbe 100644 --- a/ee/packages/media-calls/src/server/MediaCallServer.ts +++ b/ee/packages/media-calls/src/server/MediaCallServer.ts @@ -48,8 +48,8 @@ export class MediaCallServer implements IMediaCallServer { throw new Error('invalid-signal'); } - this.signalProcessor.processSignal(fromUid, signal).catch((error) => { - logger.error({ msg: 'Failed to process client signal', error, type: signal.type }); + this.signalProcessor.processSignal(fromUid, signal).catch((err) => { + logger.error({ msg: 'Failed to process client signal', err, type: signal.type }); }); } @@ -81,7 +81,7 @@ export class MediaCallServer implements IMediaCallServer { if (error && typeof error === 'object' && error instanceof CallRejectedError) { rejectionReason = error.callRejectedReason; } else { - logger.error({ msg: 'Failed to create a requested call', params, error }); + logger.error({ msg: 'Failed to create a requested call', params, err: error }); } const originalId = params.requestedCallId || params.parentCallId; diff --git a/ee/packages/media-calls/src/sip/Session.ts b/ee/packages/media-calls/src/sip/Session.ts index 48ebcf0ae7a5f..302eabf2aa768 100644 --- a/ee/packages/media-calls/src/sip/Session.ts +++ b/ee/packages/media-calls/src/sip/Session.ts @@ -47,8 +47,8 @@ export class SipServerSession { return; } - sipCall.reactToCallChanges(otherParams).catch((error) => { - logger.error({ msg: 'Failed to react to call changes', error, call: sipCall.call, otherParams }); + sipCall.reactToCallChanges(otherParams).catch((err) => { + logger.error({ msg: 'Failed to react to call changes', err, call: sipCall.call, otherParams }); }); } @@ -140,8 +140,8 @@ export class SipServerSession { this.srf.invite((req, res) => { logger.debug('Received a call on drachtio.'); - void this.processInvite(req, res).catch((error) => { - logger.error({ msg: 'Error processing Drachtio Invite', error }); + void this.processInvite(req, res).catch((err) => { + logger.error({ msg: 'Error processing Drachtio Invite', err }); }); }); } @@ -189,8 +189,8 @@ export class SipServerSession { res.send(exception.sipErrorCode); } - private onDrachtioError(error: unknown, socket?: Socket): void { - logger.error({ msg: 'Drachtio Service Error', error }); + private onDrachtioError(err: unknown, socket?: Socket): void { + logger.error({ msg: 'Drachtio Service Error', err }); if (this.isEnabledOnSettings(this.settings)) { return; diff --git a/ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts b/ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts index 497dde10026c1..3d0284c543548 100644 --- a/ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts +++ b/ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts @@ -172,8 +172,8 @@ export class IncomingSipCall extends BaseSipCall { calleeAgent.onRemoteDescriptionChanged(this.call._id, negotiationId); logger.debug({ msg: 'modify', method: 'IncomingSipCall.createDialog', req: this.session.stripDrachtioServerDetails(req) }); - } catch (error) { - logger.error({ msg: 'An unexpected error occured while processing a modify event on an IncomingSipCall dialog', error }); + } catch (err) { + logger.error({ msg: 'An unexpected error occured while processing a modify event on an IncomingSipCall dialog', err }); try { res.send(SipErrorCodes.INTERNAL_SERVER_ERROR); @@ -260,8 +260,8 @@ export class IncomingSipCall extends BaseSipCall { if (res.status === 202) { logger.debug({ msg: 'REFER was accepted', method: 'IncomingSipCall.processTransferredCall' }); } - } catch (error) { - logger.debug({ msg: 'REFER failed', method: 'IncomingSipCall.processTransferredCall', error }); + } catch (err) { + logger.debug({ msg: 'REFER failed', method: 'IncomingSipCall.processTransferredCall', err }); if (!call.ended) { void mediaCallDirector.hangupByServer(call, 'sip-refer-failed'); } @@ -365,8 +365,8 @@ export class IncomingSipCall extends BaseSipCall { answer = await this.sipDialog.modify(negotiation.offer.sdp).catch(() => { logger.debug('modify failed'); }); - } catch (error) { - logger.error({ msg: 'Error on IncomingSipCall.processCalleeNegotiation', error }); + } catch (err) { + logger.error({ msg: 'Error on IncomingSipCall.processCalleeNegotiation', err }); } if (!answer) { diff --git a/ee/packages/media-calls/src/sip/providers/OutgoingSipCall.ts b/ee/packages/media-calls/src/sip/providers/OutgoingSipCall.ts index 09fe0d8e98e85..72b544c51028e 100644 --- a/ee/packages/media-calls/src/sip/providers/OutgoingSipCall.ts +++ b/ee/packages/media-calls/src/sip/providers/OutgoingSipCall.ts @@ -169,7 +169,7 @@ export class OutgoingSipCall extends BaseSipCall { ); } catch (error) { this.sipDialog = null; - logger.error({ msg: 'OutgoingSipCall.createDialog - failed to create sip dialog', error, callId: call._id }); + logger.error({ msg: 'OutgoingSipCall.createDialog - failed to create sip dialog', err: error, callId: call._id }); const errorCode = this.getSipErrorCode(error); if (errorCode) { void mediaCallDirector.hangupByServer(call, `sip-error-${errorCode}`); @@ -224,8 +224,8 @@ export class OutgoingSipCall extends BaseSipCall { callerAgent.onRemoteDescriptionChanged(this.call._id, negotiationId); logger.debug({ msg: 'modify', method: 'OutgoingSipCall.createDialog', req: this.session.stripDrachtioServerDetails(req) }); - } catch (error) { - logger.error({ msg: 'An unexpected error occured while processing a modify event on an OutgoingSipCall dialog', error }); + } catch (err) { + logger.error({ msg: 'An unexpected error occured while processing a modify event on an OutgoingSipCall dialog', err }); try { res.send(SipErrorCodes.INTERNAL_SERVER_ERROR); @@ -295,8 +295,8 @@ export class OutgoingSipCall extends BaseSipCall { answer = await this.sipDialog.modify(negotiation.offer.sdp).catch(() => { logger.debug('modify failed'); }); - } catch (error) { - logger.error({ msg: 'Error on OutgoingSipCall.processNegotiations', error }); + } catch (err) { + logger.error({ msg: 'Error on OutgoingSipCall.processNegotiations', err }); } if (!answer) { @@ -361,8 +361,8 @@ export class OutgoingSipCall extends BaseSipCall { if (res.status === 202) { logger.debug({ msg: 'REFER was accepted', method: 'OutgoingSipCall.processTransferredCall' }); } - } catch (error) { - logger.error({ msg: 'REFER failed', method: 'OutgoingSipCall.processTransferredCall', error, callId: call._id }); + } catch (err) { + logger.error({ msg: 'REFER failed', method: 'OutgoingSipCall.processTransferredCall', err, callId: call._id }); if (!call.ended) { void mediaCallDirector.hangupByServer(call, 'sip-refer-failed'); }