Skip to content

Conversation

@mydea
Copy link
Member

@mydea mydea commented Jul 10, 2024

Small optimization using the new hook cleanup capabilities to remove unused hooks.

Ref PR to do this in angular: #12786

@mydea mydea requested review from AbhiPrasad, Lms24 and lforst July 10, 2024 15:06
@mydea mydea self-assigned this Jul 10, 2024
@mydea mydea requested a review from a team as a code owner July 10, 2024 15:06
@github-actions
Copy link
Contributor

github-actions bot commented Jul 10, 2024

size-limit report 📦

Path Size
@sentry/browser 22.3 KB (-0.02% 🔽)
@sentry/browser (incl. Tracing) 33.67 KB (+0.06% 🔺)
@sentry/browser (incl. Tracing, Replay) 69.45 KB (+0.04% 🔺)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 62.78 KB (+0.05% 🔺)
@sentry/browser (incl. Tracing, Replay with Canvas) 73.5 KB (+0.04% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback) 86.16 KB (+0.03% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback, metrics) 88.01 KB (+0.03% 🔺)
@sentry/browser (incl. metrics) 26.59 KB (-0.02% 🔽)
@sentry/browser (incl. Feedback) 38.98 KB (0%)
@sentry/browser (incl. sendFeedback) 26.92 KB (+0.01% 🔺)
@sentry/browser (incl. FeedbackAsync) 31.54 KB (+0.01% 🔺)
@sentry/react 25.07 KB (+0.08% 🔺)
@sentry/react (incl. Tracing) 36.74 KB (+0.12% 🔺)
@sentry/vue 26.41 KB (0%)
@sentry/vue (incl. Tracing) 35.55 KB (+0.06% 🔺)
@sentry/svelte 22.44 KB (-0.02% 🔽)
CDN Bundle 23.52 KB (-0.03% 🔽)
CDN Bundle (incl. Tracing) 35.44 KB (+0.06% 🔺)
CDN Bundle (incl. Tracing, Replay) 69.55 KB (+0.03% 🔺)
CDN Bundle (incl. Tracing, Replay, Feedback) 74.75 KB (+0.03% 🔺)
CDN Bundle - uncompressed 69 KB (-0.03% 🔽)
CDN Bundle (incl. Tracing) - uncompressed 104.85 KB (+0.06% 🔺)
CDN Bundle (incl. Tracing, Replay) - uncompressed 215.25 KB (+0.03% 🔺)
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 227.96 KB (+0.03% 🔺)
@sentry/nextjs (client) 36.6 KB (+0.08% 🔺)
@sentry/sveltekit (client) 34.33 KB (+0.08% 🔺)
@sentry/node 130.8 KB (-0.01% 🔽)
@sentry/node - without tracing 91.88 KB (-0.01% 🔽)
@sentry/aws-serverless 117.06 KB (-0.01% 🔽)

Small optimization using the new hook cleanup capabilities to remove unused hooks.
}

if (activeSpan) {
if (activeSpan && !spanToJSON(activeSpan).timestamp) {
Copy link
Member Author

Choose a reason for hiding this comment

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

While debugging a test failure, I noticed that this surfaced another problem - we were potentially double-ending the span here. If the idle span already ended on it's own, we do not want to/need to end it anymore here! Calling this twice lead to some issues as it tried to remove the hooks twice, ...

const cbIndex = hooks.indexOf(callback);
// @ts-expect-error We assue the types are correct
const cbIndex = hooks.indexOf(callback);
if (cbIndex > -1) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Also adding this safeguard that was missing before - if trying to remove a hook twice, this should not fail and remove the first entry or similar.

@mydea mydea merged commit deb12d5 into develop Jul 11, 2024
@mydea mydea deleted the fn/cleanup-on branch July 11, 2024 14:46
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.

3 participants