From ed2a0e64ff82719f13bf2f4735092d0f4982bd7b Mon Sep 17 00:00:00 2001 From: Jaya Allamsetty <54324652+jallamsetty1@users.noreply.github.com> Date: Mon, 12 Sep 2022 10:41:30 -0400 Subject: [PATCH] fix(stats): Skip bandwidth calc if there is no uplink/downlink bitrate. This fixes an error that gets logged when no media is being sent/received by the endpoint. Logger.js:154 2022-09-12T14:40:53.476Z [modules/statistics/AvgRTPStatsReporter.js] : bandwidth_upload - invalid value for idx: 0 --- modules/statistics/AvgRTPStatsReporter.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/statistics/AvgRTPStatsReporter.js b/modules/statistics/AvgRTPStatsReporter.js index f0e00c1687..8ea2f87ff9 100644 --- a/modules/statistics/AvgRTPStatsReporter.js +++ b/modules/statistics/AvgRTPStatsReporter.js @@ -40,10 +40,12 @@ class AverageStatReport { * @param {number} nextValue */ addNext(nextValue) { + if (typeof nextValue === 'undefined') { + return; + } + if (typeof nextValue !== 'number') { - logger.error( - `${this.name} - invalid value for idx: ${this.count}`, - nextValue); + logger.error(`${this.name} - invalid value for idx: ${this.count}`, nextValue); } else if (!isNaN(nextValue)) { this.sum += nextValue; this.samples.push(nextValue);