-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(core): Call getCurrentHubShim when accessing __SENTRY__.hub
#12160
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
Conversation
size-limit report 📦
|
isOlderThan to AsyncContextStackisOlderThan on __SENTRY__.hub
isOlderThan on __SENTRY__.hubgetCurrentHubShim when accessing __SENTRY__.hub
a9f6e83 to
9904d28
Compare
c84413e to
f3ddaac
Compare
| export function getCurrentHubShim(): Hub & { | ||
| getStackTop: () => { client: Client | undefined; scope: Scope }; | ||
| isOlderThan: () => boolean; | ||
| } { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed: We actually export this publicly from @sentry/core (not sure why we did this at all). Do we care that we widen the return type here?
| // (e.g. our loader script) accessing properties on `window.__SENTRY__.hub`. | ||
| // This will just call the `getCurrentHubShim` function, as if users would interact with `getCurrentHub`. | ||
| // eslint-disable-next-line deprecation/deprecation | ||
| Object.defineProperty(sentry, 'hub', { get: () => getCurrentHubShim(), enumerable: true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second oof: Referencing getCurrentHubShim here actually increases bundle size by +1% because previously, getCurrentHub(Shim) was completely optional :(
|
Closing this because of the bundle size hit. We thought of another solution 🙃 |
fixes #12151
fixes getsentry/sentry-javascript-bundler-plugins#533
This PR makes a change to set our
AsyncStackStrategyonto__SENTRY__.stackinstead of__SENTRY__.hub. Instead, we now set thegetCurrentHubShimonto.hub. The shim now also has the oldisOlderThanandgetStackTop.