Skip to content

Conversation

@logaretm
Copy link
Collaborator

@logaretm logaretm commented Nov 4, 2025

Bumps the vendored-in web vitals library to include the changes between 5.0.2 <-> 5.1.0 from upstream

Changes from upstream

  • Remove visibilitychange event listeners when no longer required #627
  • Register visibility-change early #637
  • Only finalize LCP on user events (isTrusted=true) #635
  • Fallback to default getSelector if custom function is null or undefined #634

Our own Changes

  • Added addPageListener and removePageListener utilities because the upstream package changed the listeners to be added on window instead of document, so I added those utilities to avoid having to check for window every time we try to add a listener.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 24.6 kB - -
@sentry/browser - with treeshaking flags 23.09 kB - -
@sentry/browser (incl. Tracing) 41.34 kB +0.27% +108 B 🔺
@sentry/browser (incl. Tracing, Profiling) 45.62 kB +0.24% +109 B 🔺
@sentry/browser (incl. Tracing, Replay) 79.79 kB +0.11% +87 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 69.47 kB +0.14% +94 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 84.47 kB +0.1% +78 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 96.67 kB +0.11% +106 B 🔺
@sentry/browser (incl. Feedback) 41.28 kB - -
@sentry/browser (incl. sendFeedback) 29.27 kB - -
@sentry/browser (incl. FeedbackAsync) 34.2 kB - -
@sentry/react 26.29 kB - -
⛔️ @sentry/react (incl. Tracing) (max: 43.3 kB) 43.31 kB +0.28% +119 B 🔺
@sentry/vue 29.08 kB - -
⛔️ @sentry/vue (incl. Tracing) (max: 43.1 kB) 43.12 kB +0.26% +109 B 🔺
@sentry/svelte 24.61 kB - -
CDN Bundle 26.9 kB - -
CDN Bundle (incl. Tracing) 41.92 kB +0.32% +132 B 🔺
CDN Bundle (incl. Tracing, Replay) 78.44 kB +0.17% +132 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 83.88 kB +0.12% +96 B 🔺
CDN Bundle - uncompressed 78.84 kB - -
CDN Bundle (incl. Tracing) - uncompressed 124.23 kB +0.23% +284 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 240.26 kB +0.12% +284 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 253.02 kB +0.12% +284 B 🔺
@sentry/nextjs (client) 45.43 kB +0.25% +112 B 🔺
@sentry/sveltekit (client) 41.74 kB +0.29% +118 B 🔺
@sentry/node-core 50.77 kB -0.01% -1 B 🔽
@sentry/node 157.85 kB - -
@sentry/node - without tracing 92.64 kB +0.01% +1 B 🔺
@sentry/aws-serverless 106.41 kB +0.01% +2 B 🔺

View base workflow run

@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 8,933 - 8,690 +3%
GET With Sentry 1,327 15% 1,397 -5%
GET With Sentry (error only) 5,897 66% 6,120 -4%
POST Baseline 1,191 - 1,213 -2%
POST With Sentry 488 41% 561 -13%
POST With Sentry (error only) 1,035 87% 1,072 -3%
MYSQL Baseline 3,251 - 3,363 -3%
MYSQL With Sentry 377 12% 482 -22%
MYSQL With Sentry (error only) 2,656 82% 2,713 -2%

View base workflow run

@logaretm logaretm force-pushed the awad/bump-web-vitals-to-5-1 branch from 29c8b28 to 019cf99 Compare November 12, 2025 08:36
@logaretm logaretm marked this pull request as ready for review November 12, 2025 11:02
@logaretm logaretm requested review from AbhiPrasad and Lms24 November 12, 2025 11:03
// Remove the above event listener since no longer required.
// See: https://github.com/GoogleChrome/web-vitals/issues/622
removePageListener('visibilitychange', cb, { capture: true });
});
Copy link

Choose a reason for hiding this comment

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

Bug: Persistent Listeners Leak Memory.

The whenIdleOrHidden function creates a memory leak by calling onHidden(cb) which adds permanent visibilitychange and pagehide event listeners that are never removed. These listeners persist even after the callback has executed via runOnce, causing unnecessary memory consumption. This affects LCP measurement cleanup where stopListening is called via this function but the onHidden listeners remain active.

Fix in Cursor Fix in Web

@logaretm logaretm force-pushed the awad/bump-web-vitals-to-5-1 branch from d9171bb to dcbfc72 Compare November 12, 2025 12:39
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.

2 participants