Skip to content

Commit

Permalink
Handle when rtcIceCandidateStatsReport is undefined
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
phi-line committed Jul 17, 2024
1 parent bf1f508 commit a6ca00c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/twilio/preflight/preflight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down

0 comments on commit a6ca00c

Please sign in to comment.