decrement count on abandoned call (#228)

fix typo so correct error message is logged
This commit is contained in:
Sam Machin
2026-07-03 17:11:46 +02:00
committed by GitHub
parent 4fb5acaf40
commit 37e4dea705
+15 -1
View File
@@ -665,7 +665,21 @@ class CallSession extends Emitter {
} }
} }
} catch (err) { } catch (err) {
if ('abandonded' !== err.message) this.logger.error({err}, `Error setting up outbound call to: ${uris}`); if ('abandoned' !== err.message) this.logger.error({err}, `Error setting up outbound call to: ${uris}`);
/* the call count was incremented on 'init' but we bailed out before connecting (e.g. caller
hung up before the B leg answered), so we must decrement it here - no failure response is
sent on this path, so the res.once('end') safety net in middleware would not fire.
nudgeCallCounts is a no-op if the count was already decremented elsewhere. */
const {writeCallCount, writeCallCountSP, writeCallCountApp} = this.req.srf.locals;
nudgeCallCounts(this.req, 'failure', {
service_provider_sid: this.service_provider_sid,
account_sid: this.account_sid,
application_sid: this.application_sid,
callId: this.req.locals.callId
}, this.decrKey, {writeCallCountSP, writeCallCount, writeCallCountApp})
.catch((err) => this.logger.error(err, 'Error decrementing call counts'));
this.emit('failed'); this.emit('failed');
this.srf.endSession(this.req); this.srf.endSession(this.req);
this.rtpEngineResource.destroy(); this.rtpEngineResource.destroy();