Skip to content
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

ref(core): Rename Hub to AsyncContextStack & remove unneeded methods #11630

Merged
merged 2 commits into from
Apr 16, 2024

Conversation

mydea
Copy link
Member

@mydea mydea commented Apr 16, 2024

Should save some bundle size...! I also moved stuff around a bit so we don't have so much somewhat unrelated stuff packed into the former hub.ts file - needed some work to avoid circular dependencies, but I think it's fine now.

I left the stuff we actually need in, and renamed it for clarity so this is not confusing anymore.

closes #11482

@mydea mydea requested review from Lms24 and AbhiPrasad April 16, 2024 14:11
@mydea mydea self-assigned this Apr 16, 2024
Comment on lines +135 to +143
const sentry = getSentryCarrier(registry) as { hub?: AsyncContextStack };

// If there's no hub, or its an old API, assign a new one
if (sentry.hub) {
return sentry.hub;
}

sentry.hub = new AsyncContextStack(getDefaultCurrentScope(), getDefaultIsolationScope());
return sentry.hub;
Copy link
Member

Choose a reason for hiding this comment

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

can we stop referencing it by .hub here?

Copy link
Member Author

Choose a reason for hiding this comment

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

sadly not because some stuff like the loader depends on this 😬 @Lms24 learned this the hard way I believe?

Copy link
Member Author

Choose a reason for hiding this comment

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

that's also the reason that this still has a getClient() method!

Copy link
Member

Choose a reason for hiding this comment

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

yes, if we remove/rename .hub our loader tests will fail because our loader script accesses __SENTRY__.hub.getClient() to check if the SDK was initialized before the loader otherwise initializes the SDK (at least that's what I think it does; the script certainly makes the access). So I guess we can only remove this once we update the loader script 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

we can still do this when v8 becomes stable I guess, but it's possibly not worth it too as it may break stuff weirdly I guess that depends on internals 😅

Copy link
Member

Choose a reason for hiding this comment

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

could we leave a comment about this somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

See #11633 👍

Copy link
Contributor

size-limit report 📦

Path Size
@sentry/browser 21.67 KB (-2.23% 🔽)
@sentry/browser (incl. Tracing) 31.28 KB (-1.55% 🔽)
@sentry/browser (incl. Tracing, Replay) 66.59 KB (-0.73% 🔽)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 59.99 KB (-0.84% 🔽)
@sentry/browser (incl. Tracing, Replay with Canvas) 70.43 KB (-0.67% 🔽)
@sentry/browser (incl. Tracing, Replay, Feedback) 80.28 KB (-0.64% 🔽)
@sentry/browser (incl. Feedback) 35.24 KB (-1.31% 🔽)
@sentry/browser (incl. Feedback, Feedback Modal) 35.25 KB (-1.31% 🔽)
@sentry/browser (incl. Feedback, Feedback Modal, Feedback Screenshot) 37.27 KB (-1.24% 🔽)
@sentry/browser (incl. sendFeedback) 26.46 KB (-1.81% 🔽)
@sentry/react 24.35 KB (-1.97% 🔽)
@sentry/react (incl. Tracing) 34.17 KB (-1.41% 🔽)
@sentry/vue 25.2 KB (-2.04% 🔽)
@sentry/vue (incl. Tracing) 32.99 KB (-1.45% 🔽)
@sentry/svelte 21.79 KB (-2.22% 🔽)
CDN Bundle 24.03 KB (-1.82% 🔽)
CDN Bundle (incl. Tracing) 32.58 KB (-1.26% 🔽)
CDN Bundle (incl. Tracing, Replay) 66.22 KB (-0.57% 🔽)
CDN Bundle (incl. Tracing, Replay, Feedback) 82.4 KB (-0.49% 🔽)
CDN Bundle - uncompressed 70.86 KB (-2.79% 🔽)
CDN Bundle (incl. Tracing) - uncompressed 96.98 KB (-2.06% 🔽)
CDN Bundle (incl. Tracing, Replay) - uncompressed 206.64 KB (-0.98% 🔽)
@sentry/nextjs (client) 33.51 KB (-1.51% 🔽)
@sentry/sveltekit (client) 31.77 KB (-1.53% 🔽)
@sentry/node 124.18 KB (+3.35% 🔺)

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Nice, great size reduction!

Took the liberty to link this in #11482 because afaict this closes the issue 🎉

@mydea mydea merged commit d5ac938 into develop Apr 16, 2024
95 checks passed
@mydea mydea deleted the fn/remove-hub-methods branch April 16, 2024 14:31
mydea added a commit that referenced this pull request Apr 16, 2024
AbhiPrasad added a commit that referenced this pull request Apr 18, 2024
Now that #11630 was
merged in, we can remove `setupGlobalHub`.
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.

[v8] Remove public APIs around Hub class
3 participants