[@sentry/svelte] Component tracking with withSentryConfig + webpack breaks Svelte 5 runes mode #15259
Open
3 tasks done
Labels
Package: svelte
Issues related to the Sentry Svelte SDK
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/svelte
SDK Version
8.52.1
Framework Version
Svelte v5.19.6
Link to Sentry event
No response
Reproduction Example/SDK Setup
Repro: https://github.com/scottohara/svelte5-withsentryconfig-bug
The issue occurs when the following is true:
let now = $state(new Date().toString());
)withSentryConfig()
to enable component tracking, e.g.Steps to Reproduce
Setup
git clone https://github.com/scottohara/svelte5-withsentryconfig-bug.git cd svelte5-withsentryconfig-bug npm install webpack
Verify working
At this point, open the file
dist/index.html
in your browser. You should see a message like:This confirms that app builds & runs successfully without component tracking.
Enable component tracking
The
WITH_SENTRY=1
environment variable instructs the webpack config to wrap the svelte-loader options inwithSentryConfig()
.Now open (or refresh) the
dist/index.html
page in your browser. You should now see a blank page, and in the browser console the following error:When caught, the error message is in fact:
Expected Result
When component tracking is enabled (in the example repo, by passing
WITH_SENTRY=1
to the webpack command; the app should not error and should display the same as when component tracking is disabled.Actual Result
With component tracking disabled
A successful render, and no console errors:
With component tracking enabled
A failed render (blank page), and the Svelte legacy error:
Why does this happen?
I believe that the root cause is the code in
@sentry/svelte
that does component tracking uses thebeforeUpdate(...)
lifecycle method.This lifecycle method is deprecated in Svelte 5.
It may be the case that
withSentryConfig()
was never designed to be used with webpack + svelte-loader (as it doesn't seem to have any issues when used in a Vite-based Svelte5 project).However prior to Svelte 5 and runes mode, using
withSentryConfig
in webpack + svelte-loader in this way did not throw any errors.The text was updated successfully, but these errors were encountered: