-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(sveltekit): Add wrapper for server load function #7416
Conversation
size-limit report 📦
|
b2db998
to
e4aa3f4
Compare
e4aa3f4
to
afddce3
Compare
return new Proxy(origLoad, { | ||
apply: async (wrappingTarget, thisArg, args: Parameters<ServerLoad>) => { | ||
try { | ||
return await wrappingTarget.apply(thisArg, args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we do the same here as we just fixed in next, return the original promise, and do the capturing of errors separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see: #7456
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is freaking cursed that this is even a possibility LOL
but yes we should 😞
closes #7403
Add wrapper for server-side load function.
Also went ahead and fixed the mechanism type to beNvm I misunderstood, changed this decision.instrument
, sincesveltekit
is not an accepted value.Using Proxy for this which I assume is fine, but we can avoid using it if needed
Usage:
We also special case errors coming from the SvelteKit
error
helper.If users defined a load function like so:
We would not capture that thrown error as it is a 404. In the future we can provide a way to opt-in to 4xx errors.