Skip to content

fix(browser): Guard against undefined nextHopProtocol #16806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

AbhiPrasad
Copy link
Member

@AbhiPrasad AbhiPrasad commented Jul 3, 2025

fixes #16804

Although PerformanceResourceTiming.nextHopProtocol is available in all the browsers we support in v9, I think adding an extra guard is reasonable to make it easier for older browser support (it's hard to polyfill some of the performance apis).

This PR just adds a condition if (resourceTiming.nextHopProtocol != undefined).

Used cursor to generate some tests for the resourceTimingToSpanAttributes I extracted out.

@AbhiPrasad AbhiPrasad requested a review from a team July 3, 2025 16:47
@AbhiPrasad AbhiPrasad self-assigned this Jul 3, 2025
@AbhiPrasad AbhiPrasad requested review from stephanie-anderson and chargome and removed request for a team July 3, 2025 16:47
Copy link
Contributor

github-actions bot commented Jul 3, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.99 kB - -
@sentry/browser - with treeshaking flags 23.76 kB - -
@sentry/browser (incl. Tracing) 39.59 kB +0.02% +7 B 🔺
@sentry/browser (incl. Tracing, Replay) 77.7 kB +0.02% +8 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.79 kB +0.02% +11 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 82.46 kB +0.02% +10 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 94.58 kB +0.01% +9 B 🔺
@sentry/browser (incl. Feedback) 40.75 kB - -
@sentry/browser (incl. sendFeedback) 28.7 kB - -
@sentry/browser (incl. FeedbackAsync) 33.59 kB - -
@sentry/react 25.76 kB - -
@sentry/react (incl. Tracing) 41.59 kB +0.03% +9 B 🔺
@sentry/vue 28.37 kB - -
@sentry/vue (incl. Tracing) 41.41 kB +0.02% +7 B 🔺
@sentry/svelte 24.01 kB - -
CDN Bundle 25.5 kB - -
CDN Bundle (incl. Tracing) 39.61 kB +0.03% +10 B 🔺
CDN Bundle (incl. Tracing, Replay) 75.51 kB +0.02% +9 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 80.97 kB +0.01% +8 B 🔺
CDN Bundle - uncompressed 74.5 kB - -
CDN Bundle (incl. Tracing) - uncompressed 117.66 kB +0.03% +34 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 231.71 kB +0.02% +34 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 244.53 kB +0.02% +34 B 🔺
@sentry/nextjs (client) 43.23 kB +0.03% +12 B 🔺
@sentry/sveltekit (client) 40.05 kB +0.04% +13 B 🔺
@sentry/node 162.03 kB - -
@sentry/node - without tracing 98.64 kB - -
@sentry/aws-serverless 124.4 kB - -

View base workflow run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Protocol Extraction Triggered Incorrectly

The condition if (resourceTiming.nextHopProtocol != undefined) incorrectly calls extractNetworkProtocol when nextHopProtocol is an empty string. This contradicts test expectations that extractNetworkProtocol should not be called for empty or undefined values. The condition should be if (resourceTiming.nextHopProtocol) to properly handle these cases.

packages/browser/src/tracing/resource-timing.ts#L18-L19

const timingSpanData: Array<Parameters<Span['setAttribute']>> = [];
if (resourceTiming.nextHopProtocol != undefined) {

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PerformanceResourceTiming.nextHopProtocol is used without check for support
2 participants