ref(sveltekit): Split up universal and server load wrappers#7652
Merged
ref(sveltekit): Split up universal and server load wrappers#7652
Conversation
262ff62 to
87f0538
Compare
87f0538 to
e950daf
Compare
AbhiPrasad
approved these changes
Mar 29, 2023
| * @param origLoad SvelteKit user defined universal `load` function | ||
| */ | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| export declare function wrapLoadWithSentry<T extends (...args: any) => any>(origLoad: T): T; |
Contributor
There was a problem hiding this comment.
Can we use unknown instead of any?
Member
Author
Contributor
size-limit report 📦
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
handleLoadWithSentrywrapper function into two functions on the server side:handleLoadWithSentryto wrap universal load on server and clienthandleServerLoadWithSentryto 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.PageDataorServerLayoutData) are generated at build time per route/page. Hence, we cannot access them.If we manage to get the
handleLoadhook 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.