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

[Sveltekit] Sveltekit auto instrumentation in vite plugin causes load functions to invalidate on every route change #8610

Closed
3 tasks done
madeleineostoja opened this issue Jul 21, 2023 · 3 comments · Fixed by #8801
Assignees
Labels
Package: sveltekit Issues related to the Sentry SvelteKit SDK Type: Bug

Comments

@madeleineostoja
Copy link

madeleineostoja commented Jul 21, 2023

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/sveltekit

SDK Version

7.57.0

Framework Version

Sveltekit 1.22.1

Link to Sentry event

No response

SDK Setup

No response

Steps to Reproduce

  1. Add Sentry's load instrumentation via the vite plugin for Svetlekit as outlined in the docs
  2. Create a +layout.server.ts in the root of the project
  3. See it re-run on every single route change despite having no dependencies on url/params/etc

Expected Result

Layout load should not re-run unless its dependencies change or its explicitly invalidated

Actual Result

Layout load is invalidated on every route change, due to Sentry's instrumentation of load.

Adding autoInstrument: false to the vite plugin options resolves the issue.

Took me AGES to debug why my loads were rerunning constantly, breaking my app (I hydrate stores when they first run, and rehydrate on manual invalidation). This should be a huge warning in the docs if its not fixable due to patching sveltekit's fetch at the moment.

@Lms24
Copy link
Member

Lms24 commented Jul 24, 2023

Hi @madeleineostoja, thanks for reporting and I'm very sorry for making this so hard to track down. It seems like our fix from #8391 is flawed. Recently we were notified about a better way of patching the global fetch instrumentation in SvelteKit, which might just fix the caching/invalidation issue.

I'll look into this soon. I'd be more than happy to get rid of our custom fetch instrumentation in SvelteKit anyway 😅

Also yet again another example why an actual client-side handleFetch hook would be great.

@Lms24
Copy link
Member

Lms24 commented Aug 11, 2023

Hey @madeleineostoja, I finally had some time to look at this and it turns out it's not related to fetch for once. Instead, a simple access to route.id in the server load function (which our wrapper around load does) causes route invalidations. More details in #8801. We'll include the fix in the next SDK release (expect it at the beginning of next week).

@Lms24
Copy link
Member

Lms24 commented Aug 16, 2023

The fix isn't released yet but I just merged it. It'll go out with the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: sveltekit Issues related to the Sentry SvelteKit SDK Type: Bug
Projects
Archived in project
2 participants