You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it just me or are SvelteKit load functions really confusing...?
I have spent the last couple days debugging an issue that turns out to arise from load functions rerunning because of the way SvelteKit tracks load function dependencies and then reruns them if any dependency changes.
Despite reading the docs multiple times and working with sveltekit for years I am still having a hard time wrapping my mind around:
when exactly which load functions rerun
how exactly the dependency tracking works, especially in cases where event.parent(), event.untrack(), event.depends() are mixed and matched
why a POST request to a given route would also trigger a GET request to that routes load function after the POST (which was a big footgun for us)
All in all load functions feel like a very leaky abstraction to me. I have to really study and understand the internals of sveltekit to use them productively.
For our team we are currently deciding to go the other way - use load functions less, don't rely in any way on its dependency tracking, and especially never use invalidate() or invalidateAll() because it has led to subtle and hard-to-pin-down bugs for us in the past.
I wonder how the sveltekit team feels about this...? Are load functions as-is the intended interface for future SvelteKit versions, or is there something else in the pipeline?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Is it just me or are SvelteKit load functions really confusing...?
I have spent the last couple days debugging an issue that turns out to arise from load functions rerunning because of the way SvelteKit tracks load function dependencies and then reruns them if any dependency changes.
Despite reading the docs multiple times and working with sveltekit for years I am still having a hard time wrapping my mind around:
event.parent()
,event.untrack()
,event.depends()
are mixed and matchedAll in all load functions feel like a very leaky abstraction to me. I have to really study and understand the internals of sveltekit to use them productively.
For our team we are currently deciding to go the other way - use load functions less, don't rely in any way on its dependency tracking, and especially never use
invalidate()
orinvalidateAll()
because it has led to subtle and hard-to-pin-down bugs for us in the past.I wonder how the sveltekit team feels about this...? Are load functions as-is the intended interface for future SvelteKit versions, or is there something else in the pipeline?
Beta Was this translation helpful? Give feedback.
All reactions