ref(sveltekit): Split up universal and server load wrappers #7652
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 splits up the previously generic
handleLoadWithSentry
wrapper function into two functions on the server side:handleLoadWithSentry
to wrap universal load on server and clienthandleServerLoadWithSentry
to wrap server load on the server (duh)It further adjusts types on the client as well as on the server side to return a generic. The very liberal typing of the functions' generic is on purpose because any type that's more narrowed down (e.g.
T extends Load
) would create a type error with the users' actual load types. These types (e.g.PageData
orServerLayoutData
) are generated at build time per route/page. Hence, we cannot access them.If we manage to get the
handleLoad
hook into SvelteKit we should deprecate these functions and use that new handler which we'll also be able to type better.Furthermore, I extracted some common trace propagation data extraction logic and added/adjusted tests.
closes #7526
I'll update the readme in a separate PR as more than just the load function section needs to be updated.