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

fix(core): Call getCurrentHubShim when accessing __SENTRY__.hub #12160

Closed
wants to merge 4 commits into from

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented May 22, 2024

fixes #12151
fixes getsentry/sentry-javascript-bundler-plugins#533

This PR makes a change to set our AsyncStackStrategy onto __SENTRY__.stack instead of __SENTRY__.hub. Instead, we now set the getCurrentHubShim onto .hub. The shim now also has the old isOlderThan and getStackTop.

@Lms24 Lms24 requested a review from mydea May 22, 2024 10:42
Copy link
Contributor

github-actions bot commented May 22, 2024

size-limit report 📦

Path Size
@sentry/browser 22.01 KB (+1.11% 🔺)
@sentry/browser (incl. Tracing) 33.18 KB (+0.81% 🔺)
@sentry/browser (incl. Tracing, Replay) 68.5 KB (+0.35% 🔺)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 61.94 KB (+0.42% 🔺)
@sentry/browser (incl. Tracing, Replay with Canvas) 72.54 KB (+0.35% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback) 84.61 KB (+0.32% 🔺)
@sentry/browser (incl. Feedback) 38.04 KB (+0.7% 🔺)
@sentry/browser (incl. sendFeedback) 26.58 KB (+0.9% 🔺)
@sentry/browser (incl. FeedbackAsync) 31.01 KB (+0.81% 🔺)
@sentry/react 24.68 KB (+0.94% 🔺)
@sentry/react (incl. Tracing) 36.14 KB (+0.7% 🔺)
@sentry/vue 25.98 KB (+0.98% 🔺)
@sentry/vue (incl. Tracing) 34.99 KB (+0.73% 🔺)
@sentry/svelte 22.15 KB (+1.11% 🔺)
CDN Bundle 24.35 KB (+0.17% 🔺)
CDN Bundle (incl. Tracing) 34.37 KB (+0.05% 🔺)
CDN Bundle (incl. Tracing, Replay) 68.1 KB (+0.07% 🔺)
CDN Bundle (incl. Tracing, Replay, Feedback) 73.08 KB (+0.05% 🔺)
CDN Bundle - uncompressed 71.62 KB (+0.22% 🔺)
CDN Bundle (incl. Tracing) - uncompressed 102.03 KB (+0.15% 🔺)
CDN Bundle (incl. Tracing, Replay) - uncompressed 211.65 KB (+0.07% 🔺)
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 224.01 KB (+0.07% 🔺)
@sentry/nextjs (client) 35.43 KB (+0.75% 🔺)
@sentry/sveltekit (client) 33.79 KB (+0.79% 🔺)
@sentry/node 114.31 KB (+0.2% 🔺)
@sentry/aws-serverless 103.2 KB (+0.2% 🔺)

@Lms24 Lms24 changed the title fix(core): Re-introduce isOlderThan to AsyncContextStack fix(core): Re-introduce isOlderThan on __SENTRY__.hub May 22, 2024
@Lms24 Lms24 marked this pull request as ready for review May 22, 2024 13:12
@Lms24 Lms24 changed the title fix(core): Re-introduce isOlderThan on __SENTRY__.hub fix(core): Call getCurrentHubShim when accessing __SENTRY__.hub May 22, 2024
@Lms24 Lms24 force-pushed the lms/fix-browser-carrier-hub-isOlderThan branch from a9f6e83 to 9904d28 Compare May 22, 2024 13:20
@Lms24 Lms24 force-pushed the lms/fix-browser-carrier-hub-isOlderThan branch from c84413e to f3ddaac Compare May 22, 2024 14:17
Comment on lines +25 to +28
export function getCurrentHubShim(): Hub & {
getStackTop: () => { client: Client | undefined; scope: Scope };
isOlderThan: () => boolean;
} {
Copy link
Member Author

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 });
Copy link
Member Author

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 :(

@Lms24
Copy link
Member Author

Lms24 commented May 22, 2024

Closing this because of the bundle size hit. We thought of another solution 🙃

@Lms24 Lms24 closed this May 22, 2024
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.

isOlderThan is not a function V8 causes error with Square payment form
1 participant