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(sveltekit): Avoid data invalidation in wrapped client-side load functions #9071

Merged
merged 1 commit into from
Oct 2, 2023

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Sep 20, 2023

This PR fixes a data invalidation issue that appeared on the client side when auto-instrumenting or manually wrapping universal load functions. Because our wrapLoadWithSentry function accessed event.route.id, the data returned from load would be invalidated on a route change. As reported in #8818 , this caused prefetched, actually valid data to be invalidated during the navigation to the page, causing another load invocation.

To avoid this invalidation, we change the way how we read the route.id, to first use Object.getOwnPropertyDescriptor which doesn't trigger the proxy that listens to accesses. This, however, will only work for @sveltejs/kit>=1.24.0 which includes a change to the Kit-internal proxy. For older versions of kit, we continue to directly read from event.route.id, which will still cause invalidations. Not ideal but IMO the best we can do without loosing data.

I'll open a separate PR to docs, recommending to use the SDK with Kit 1.24.0 or newer (but 1.0.0 will still be the minimal supported version).

closes #8818

@Lms24 Lms24 merged commit c356073 into develop Oct 2, 2023
44 checks passed
@Lms24 Lms24 deleted the lms/fix-sveltekit-client-load-invalidation branch October 2, 2023 09:58
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.

Using the SvelteKit SDK breaks SSR functionality of TanStack Query
2 participants