From e8a7366526bc1db785f809875281766d938a892a Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Tue, 18 Feb 2025 13:03:34 -0500 Subject: [PATCH] handle exceptions if we invoke _lccCallHook with new url and it rejects for some reason (#1087) --- lib/session/call-session.js | 114 +++++++++++++++++++----------------- 1 file changed, 59 insertions(+), 55 deletions(-) diff --git a/lib/session/call-session.js b/lib/session/call-session.js index 885aa672..a6417c01 100644 --- a/lib/session/call-session.js +++ b/lib/session/call-session.js @@ -1799,62 +1799,66 @@ Duration=${duration} ` async updateCall(opts, callSid) { this.logger.debug(opts, 'CallSession:updateCall'); - if (opts.call_status) { - return this._lccCallStatus(opts); - } - if (opts.call_hook || opts.child_call_hook) { - return await this._lccCallHook(opts); - } - if (opts.listen_status || opts.stream_status) { - await this._lccListenStatus(opts); - } - if (opts.transcribe_status) { - await this._lccTranscribeStatus(opts); - } - else if (opts.mute_status) { - await this._lccMuteStatus(opts.mute_status === 'mute', callSid); - } - else if (opts.conf_hold_status) { - await this._lccConfHoldStatus(opts); - } - else if (opts.conf_mute_status) { - await this._lccConfMuteStatus(opts); - } - else if (opts.sip_request) { - const res = await this._lccSipRequest(opts, callSid); - return {status: res.status, reason: res.reason}; - } else if (opts.dtmf) { - await this._lccDtmf(opts, callSid); - } - else if (opts.record) { - await this.notifyRecordOptions(opts.record); - } - else if (opts.tag) { - return this._lccTag(opts); - } - else if (opts.conferenceParticipantAction) { - return this._lccConferenceParticipantAction(opts.conferenceParticipantAction); - } - else if (opts.dub) { - return this._lccDub(opts.dub, callSid); - } - else if (opts.boostAudioSignal) { - return this._lccBoostAudioSignal(opts, callSid); - } - else if (opts.media_path) { - return this._lccMediaPath(opts.media_path, callSid); - } - else if (opts.llm_tool_output) { - return this._lccToolOutput(opts.tool_call_id, opts.llm_tool_output, callSid); - } - else if (opts.llm_update) { - return this._lccLlmUpdate(opts.llm_update, callSid); - } + try { + if (opts.call_status) { + return this._lccCallStatus(opts); + } + if (opts.call_hook || opts.child_call_hook) { + return await this._lccCallHook(opts); + } + if (opts.listen_status || opts.stream_status) { + await this._lccListenStatus(opts); + } + if (opts.transcribe_status) { + await this._lccTranscribeStatus(opts); + } + else if (opts.mute_status) { + await this._lccMuteStatus(opts.mute_status === 'mute', callSid); + } + else if (opts.conf_hold_status) { + await this._lccConfHoldStatus(opts); + } + else if (opts.conf_mute_status) { + await this._lccConfMuteStatus(opts); + } + else if (opts.sip_request) { + const res = await this._lccSipRequest(opts, callSid); + return {status: res.status, reason: res.reason}; + } else if (opts.dtmf) { + await this._lccDtmf(opts, callSid); + } + else if (opts.record) { + await this.notifyRecordOptions(opts.record); + } + else if (opts.tag) { + return this._lccTag(opts); + } + else if (opts.conferenceParticipantAction) { + return this._lccConferenceParticipantAction(opts.conferenceParticipantAction); + } + else if (opts.dub) { + return this._lccDub(opts.dub, callSid); + } + else if (opts.boostAudioSignal) { + return this._lccBoostAudioSignal(opts, callSid); + } + else if (opts.media_path) { + return this._lccMediaPath(opts.media_path, callSid); + } + else if (opts.llm_tool_output) { + return this._lccToolOutput(opts.tool_call_id, opts.llm_tool_output, callSid); + } + else if (opts.llm_update) { + return this._lccLlmUpdate(opts.llm_update, callSid); + } - // whisper may be the only thing we are asked to do, or it may that - // we are doing a whisper after having muted, paused recording etc.. - if (opts.whisper) { - return this._lccWhisper(opts, callSid); + // whisper may be the only thing we are asked to do, or it may that + // we are doing a whisper after having muted, paused recording etc.. + if (opts.whisper) { + return this._lccWhisper(opts, callSid); + } + } catch (err) { + this.logger.info({err, opts, callSid}, 'CallSession:updateCall - error updating call'); } }