Compare commits

..

2 Commits

Author SHA1 Message Date
rhonda hollis
076ca95c65 add null check for eventHook 2026-03-27 09:43:34 -07:00
Dave Horton
df30496dac fix uncaught exception referencing this.ep in freeswitch hangup scenario (#1532) 2026-03-27 08:31:32 -04:00
4 changed files with 10 additions and 29 deletions

View File

@@ -28,7 +28,6 @@ module.exports = function(srf, logger) {
registrar,
lookupClientByAccountAndUsername
} = srf.locals.dbHelpers;
const {addKey} = srf.locals.dbHelpers;
const {
writeAlerts,
AlertType
@@ -143,14 +142,6 @@ module.exports = function(srf, logger) {
rootSpan
};
/* write a short-lived Redis key mapping the original Call-ID (X-CID) to the traceId,
so sbc-inbound can look it up for CDRs even when a CANCEL is sent to sbc-inbound */
const externalCallId = req.get('X-CID');
if (externalCallId) {
addKey(`callid:${externalCallId}`, traceId, 300)
.catch((err) => logger.error(err, 'createRootSpan: error writing traceId to Redis'));
}
/**
* end the span on final failure or cancel from caller;
* otherwise it will be closed when sip dialog is destroyed

View File

@@ -1488,12 +1488,7 @@ class CallSession extends Emitter {
else if (opts.call_status === CallStatus.NoAnswer) {
if (this.direction === CallDirection.Inbound) {
if (this.res && !this.res.finalResponseSent) {
const traceId = this.req?.locals?.traceId;
this.res.send(503, {
headers: {
...(traceId && {'X-Trace-ID': traceId})
}
});
this.res.send(503);
this._callReleased();
}
}
@@ -2481,7 +2476,7 @@ Duration=${duration} `
this.logger.info(`allocated endpoint ${ep.uuid}`);
this.ep.on('destroy', () => {
this.logger.debug(`endpoint was destroyed!! ${this.ep.uuid}`);
this.logger.debug(`endpoint was destroyed!! ${this.ep?.uuid}`);
});
if (this.direction === CallDirection.Inbound || this.application?.transferredCall) {
@@ -2526,12 +2521,10 @@ Duration=${duration} `
// Send SIP error response immediately for inbound calls
if (this.res && !this.res.finalResponseSent) {
this.logger.info(`Sending ${err.status} response to SBC due to SipError`);
const traceId = this.req?.locals?.traceId;
this.res.send(err.status, {
headers: {
'X-Reason': `endpoint allocation failure: ${err.reason || 'Endpoint Allocation Failed'}`,
...(sipReasonHeader && {'Reason': sipReasonHeader}),
...(traceId && {'X-Trace-ID': traceId})
...(sipReasonHeader && {'Reason': sipReasonHeader})
}
});
this._notifyCallStatusChange({

View File

@@ -51,14 +51,12 @@ class InboundCallSession extends CallSession {
_onTasksDone() {
if (!this.res.finalResponseSent) {
const traceId = this.req.locals.traceId;
if (this._mediaServerFailure) {
this.rootSpan.setAttributes({'call.termination': 'media server failure'});
this.logger.info('InboundCallSession:_onTasksDone generating 480 due to media server failure');
this.res.send(480, {
headers: {
'X-Reason': 'crankback: media server failure',
...(traceId && {'X-Trace-ID': traceId})
'X-Reason': 'crankback: media server failure'
}
});
}
@@ -71,19 +69,14 @@ class InboundCallSession extends CallSession {
this.res.send(status, {
headers: {
'X-Reason': `endpoint allocation failure: ${reason}`,
...(sipReasonHeader && {'Reason': sipReasonHeader}),
...(traceId && {'X-Trace-ID': traceId})
...(sipReasonHeader && {'Reason': sipReasonHeader})
}
});
}
else {
this.rootSpan.setAttributes({'call.termination': 'tasks completed without answering call'});
this.logger.info('InboundCallSession:_onTasksDone auto-generating non-success response to invite');
this.res.send(603, {
headers: {
...(traceId && {'X-Trace-ID': traceId})
}
});
this.res.send(603);
}
}
this.req.removeAllListeners('cancel');

View File

@@ -286,6 +286,10 @@ class TaskLlmUltravox_S2S extends Task {
}
_sendLlmEvent(type, evt) {
if (!this.eventHook) {
this.logger.info({evt}, 'TaskLlmUltravox_S2S:_sendLlmEvent - no eventHook defined!');
return;
}
/* check whether we should notify on this event */
if (this.includeEvents.length > 0 ? this.includeEvents.includes(type) : !this.excludeEvents.includes(type)) {
this.parent.sendEventHook(evt)