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(v8/svelte): Guard component tracking beforeUpdate call #15262

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Feb 3, 2025

This PR adds a guard the Svelte SDK's component update tracking feature to catch an error thrown by Svelte 5 in Runes mode. In Runes mode, components must not call the old beforeUpdate or afterUpdate lifecycle hooks. Usually, when users do this in their code, the Svelte compiler would throw a build error. However, since our withSentryConfig wrapper adds a preprocessor that sneaks such a function call in, the compiler doesn't notice this (at least not in the webpack loader as reported in ##15259.

This PR also cleans up the preprocessor adding logic which was overcomplicated and a leftover from when we added more than one preprocessor to users' svelte configs. In general, I cleaned up some unnecessary stuff and terminology.

I'll open a follow-up PR for v9 where I'll disable update tracking by default (see #15259 (comment))

closes #15259

@Lms24 Lms24 requested review from a team as code owners February 3, 2025 09:45
@Lms24 Lms24 force-pushed the lms/fix-svelte-5-component-tracking-guard branch from fbee874 to 0a50a53 Compare February 3, 2025 09:47
@Lms24 Lms24 changed the base branch from develop to v8 February 3, 2025 09:47
@Lms24 Lms24 removed request for a team February 3, 2025 09:48
@Lms24 Lms24 self-assigned this Feb 3, 2025
Comment on lines +26 to +27
...DEFAULT_SENTRY_OPTIONS.componentTracking,
...(sentryOptions && sentryOptions.componentTracking),
Copy link
Member Author

Choose a reason for hiding this comment

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

this was a bug previously, not sure how we missed this, given we have a lot of tests...

@Lms24 Lms24 requested review from a team, lforst, AbhiPrasad and s1gr1d and removed request for a team and AbhiPrasad February 3, 2025 10:48
@Lms24 Lms24 changed the title fix(svelte): Guard component tracking beforeUpdate call fix(v8/svelte): Guard component tracking beforeUpdate call Feb 3, 2025
@Lms24 Lms24 force-pushed the lms/fix-svelte-5-component-tracking-guard branch from 4641fac to f865ebd Compare February 3, 2025 10:55
@Lms24 Lms24 merged commit d459577 into v8 Feb 3, 2025
35 checks passed
@Lms24 Lms24 deleted the lms/fix-svelte-5-component-tracking-guard branch February 3, 2025 16:30
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.

2 participants