-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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: handleLoad hooks #11313
base: main
Are you sure you want to change the base?
feat: handleLoad hooks #11313
Conversation
Adds handleLoad and handleServerLoad hooks that run before any invocation of a corresponding load function. closes #9542
|
Noting the brief discussion Rich and I had about this: The fact that you need to be very careful about which things to read in |
Is it necessary to track anything at all inside the hooks? It feels like that should happen inside the root layout instead and the hook should only be used for logging, modifying, ... |
If you implement an auth guard you may want to ensure it runs on every request |
Yeah sure, but would it be a problem to always run the hook when the load function chain starts? It feels more intuitive to me, very similar to how the handle hook works. |
|
Ah alright. But still, why do we need to track anything then? If your page load function depends on something that runs inside handleLoad it will always be there if it always runs. I don't see why you would need tracking. Maybe I just need an example that makes use of that functionality |
I believe there was discussion around providing an untracked version of event properties alongside the main tracked one at some point? Something like this would greatly help us at Sentry. For example to obtain route information. Worth noting that we don't alter any behaviour based on reading these values so I don't think it should cause an invalidation. |
@Lms24 did fly a bit under the radar, but a mechanism to not cause reruns from reading properties exists in 2.0: https://kit.svelte.dev/docs/load#rerunning-load-functions-untracking-dependencies In fact, it's used in this PR - else |
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.
a mechanism to not cause reruns from reading properties exists in 2.0:
Oh awesome, thx for clarifying! I totally missed this
Co-authored-by: Lukas Stracke <lukas.stracke@sentry.io>
Hi, is there anything I can help with to get this merged? |
Hi Lukas. There's still some deliberation ongoing due to the concern mentioned in #11313 (comment) and we're not sure how to address this yet. |
Adds handleLoad and handleServerLoad hooks that run before any invocation of a corresponding load function.
closes #9542
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.