Skip to content

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Sep 19, 2025

This PR fixes two edge cases around our client hook subscriber management:

  1. Registering the same callback instance twice on the same hook, resulted in the callback only being invoked once. Fixed by wrapping the passed callback in a function to "unique-ify" it.
  2. Unregistering one callback synchronously within the callback, caused other callbacks to not be invoked due to in-place, sync array mutation. Fixed by converting the hooks data structure from Array<Function> to Set<Function> which is resilient to sync, in-place mutation. This also lets us remove the workaround introduced in fix(browser-utils): Ensure web vital client hooks unsubscribe correctly #17272 where we initially discovered this bug.

Added regression tests for both cases that failed beforehand.

closes #17276

@Lms24 Lms24 self-assigned this Sep 19, 2025
@Lms24 Lms24 requested review from a team, stephanie-anderson, AbhiPrasad and chargome and removed request for a team and stephanie-anderson September 19, 2025 09:41
Copy link
Contributor

github-actions bot commented Sep 19, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 24.23 kB +0.02% +3 B 🔺
@sentry/browser - with treeshaking flags 22.74 kB +0.04% +7 B 🔺
@sentry/browser (incl. Tracing) 40.25 kB -0.04% -14 B 🔽
@sentry/browser (incl. Tracing, Replay) 78.63 kB -0.01% -5 B 🔽
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 68.28 kB -0.02% -11 B 🔽
@sentry/browser (incl. Tracing, Replay with Canvas) 83.29 kB -0.01% -6 B 🔽
@sentry/browser (incl. Tracing, Replay, Feedback) 95.5 kB -0.03% -25 B 🔽
@sentry/browser (incl. Feedback) 40.95 kB +0.03% +10 B 🔺
@sentry/browser (incl. sendFeedback) 28.88 kB +0.02% +3 B 🔺
@sentry/browser (incl. FeedbackAsync) 33.8 kB +0.04% +12 B 🔺
@sentry/react 25.94 kB +0.02% +5 B 🔺
@sentry/react (incl. Tracing) 42.24 kB -0.06% -24 B 🔽
@sentry/vue 28.72 kB +0.02% +5 B 🔺
@sentry/vue (incl. Tracing) 42.05 kB -0.04% -16 B 🔽
@sentry/svelte 24.25 kB +0.03% +5 B 🔺
CDN Bundle 25.74 kB -0.02% -4 B 🔽
CDN Bundle (incl. Tracing) 40.05 kB -0.05% -17 B 🔽
CDN Bundle (incl. Tracing, Replay) 76.27 kB -0.04% -24 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) 81.78 kB -0.03% -24 B 🔽
CDN Bundle - uncompressed 75.23 kB -0.01% -7 B 🔽
CDN Bundle (incl. Tracing) - uncompressed 118.59 kB -0.06% -60 B 🔽
CDN Bundle (incl. Tracing, Replay) - uncompressed 233.72 kB -0.03% -60 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 246.48 kB -0.03% -60 B 🔽
@sentry/nextjs (client) 44.24 kB -0.06% -23 B 🔽
@sentry/sveltekit (client) 40.68 kB -0.04% -15 B 🔽
@sentry/node-core 49.96 kB - -
@sentry/node 152.24 kB -0.01% -5 B 🔽
@sentry/node - without tracing 91.86 kB -0.01% -4 B 🔽
@sentry/aws-serverless 105.31 kB -0.01% -4 B 🔽

View base workflow run

Copy link
Contributor

github-actions bot commented Sep 19, 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 9,672 - 9,445 +2%
GET With Sentry 1,508 16% 1,367 +10%
GET With Sentry (error only) 6,458 67% 6,064 +6%
POST Baseline 1,289 - 1,216 +6%
POST With Sentry 561 44% 511 +10%
POST With Sentry (error only) 1,131 88% 1,062 +6%
MYSQL Baseline 3,548 - 3,303 +7%
MYSQL With Sentry 521 15% 492 +6%
MYSQL With Sentry (error only) 2,871 81% 2,654 +8%

View base workflow run

@Lms24 Lms24 merged commit 670c624 into develop Sep 19, 2025
188 checks passed
@Lms24 Lms24 deleted the lms/fix-core-client-hooks-callbacks branch September 19, 2025 10:41
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.

Improve client hook subscriber management
2 participants