Skip to content

Commit 6179229

Browse files
AbhiPrasadLms24
andauthored
fix(browser): guard nextHopProtocol when adding resource spans (#16900)
ref #16804 This was addressed with #16806, but we didn't guard every location that uses `entry.nextHopProtocol`. Will backport to v9 after merge. --------- Co-authored-by: Lukas Stracke <[email protected]>
1 parent fbf7b1c commit 6179229

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/browser-utils/src/metrics/browserMetrics.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,9 +715,13 @@ export function _addResourceSpans(
715715

716716
attributes['url.same_origin'] = resourceUrl.includes(WINDOW.location.origin);
717717

718-
const { name, version } = extractNetworkProtocol(entry.nextHopProtocol);
719-
attributes['network.protocol.name'] = name;
720-
attributes['network.protocol.version'] = version;
718+
// Checking for only `undefined` and `null` is intentional because it's
719+
// valid for `nextHopProtocol` to be an empty string.
720+
if (entry.nextHopProtocol != null) {
721+
const { name, version } = extractNetworkProtocol(entry.nextHopProtocol);
722+
attributes['network.protocol.name'] = name;
723+
attributes['network.protocol.version'] = version;
724+
}
721725

722726
const startTimestamp = timeOrigin + startTime;
723727
const endTimestamp = startTimestamp + duration;

0 commit comments

Comments
 (0)