fix(sveltekit): Avoid data invalidation in wrapped client-side load
functions
#9071
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes a data invalidation issue that appeared on the client side when auto-instrumenting or manually wrapping universal
load
functions. Because ourwrapLoadWithSentry
function accessedevent.route.id
, the data returned fromload
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 anotherload
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 fromevent.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