From 291b8a1532d5f0abec8ca4f6c8bf824555ba6107 Mon Sep 17 00:00:00 2001 From: kiem <19956136+phi-line@users.noreply.github.com> Date: Wed, 17 Jul 2024 14:41:52 -0700 Subject: [PATCH] Handle when rtcIceCandidateStatsReport is undefined In the case where rtcIceCandidateStatsReport is never set, we cannot read from one of its properties. This change ensures that a default value is set when rtcIceCandidateStatsReport is undefined. --- lib/twilio/preflight/preflight.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/twilio/preflight/preflight.ts b/lib/twilio/preflight/preflight.ts index 2525b3a5..6be60b72 100644 --- a/lib/twilio/preflight/preflight.ts +++ b/lib/twilio/preflight/preflight.ts @@ -292,7 +292,7 @@ export class PreflightTest extends EventEmitter { const report: PreflightTest.Report = { callSid: this._callSid, edge: this._edge, - iceCandidateStats: this._rtcIceCandidateStatsReport.iceCandidateStats, + iceCandidateStats: this._rtcIceCandidateStatsReport?.iceCandidateStats ?? [], networkTiming: this._networkTiming, samples: this._samples, selectedEdge: this._options.edge, @@ -302,7 +302,7 @@ export class PreflightTest extends EventEmitter { warnings: this._warnings, }; - const selectedIceCandidatePairStats = this._rtcIceCandidateStatsReport.selectedIceCandidatePairStats; + const selectedIceCandidatePairStats = this._rtcIceCandidateStatsReport?.selectedIceCandidatePairStats; if (selectedIceCandidatePairStats) { report.selectedIceCandidatePairStats = selectedIceCandidatePairStats;