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
39 changes: 18 additions & 21 deletions apps/meteor/server/services/media-call/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
}

Expand All @@ -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<void> {
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 });
}
}

Expand Down Expand Up @@ -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<void> {
Expand All @@ -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 || {};
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 });
}
}

Expand Down Expand Up @@ -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;
}
}
}
30 changes: 15 additions & 15 deletions ee/packages/media-calls/src/server/CallDirector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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) {
Expand All @@ -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<void> {
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,
Expand All @@ -342,7 +342,7 @@ class MediaCallDirector {
endedBy: agent.getMyCallActor(call),
reason: 'error',
});
throw error;
throw err;
}
}

Expand All @@ -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);
Expand All @@ -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 })),
),
);
}
Expand All @@ -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 });
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions ee/packages/media-calls/src/server/MediaCallServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
});
}

Expand Down Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions ee/packages/media-calls/src/sip/Session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
});
}

Expand Down Expand Up @@ -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 });
});
});
}
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions ee/packages/media-calls/src/sip/providers/IncomingSipCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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');
}
Expand Down Expand Up @@ -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) {
Expand Down
14 changes: 7 additions & 7 deletions ee/packages/media-calls/src/sip/providers/OutgoingSipCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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');
}
Expand Down
Loading