-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Invalidate + Goto triggers load() twice with custom identifier #10359
Comments
We just discovered the same issue in our application. Whenever we have the following code: someAPI.updateEntity(entity)
.then(async () => {
await invalidate("app:someEntity")
await goto("/url/of/entity")
}) we end up with the respective load function being called twice: To add to the fun, if we have something like this: someAPI.updateEntity(entity)
.then(async (res) => {
await invalidate("app:someEntity")
await invalidate("app:listOfEntities")
await goto("/url/of/entity")
}) we end up with the load function that has We tried that both with using URL or custom identifier, the results are the same. I'd argue that the severity is more than "annoyance", as this slows down the page, as we have to wait for 2 or 3 repeated GET requests to finish. Also it puts unnecessary pressure on the API server, as it has to serve a lot of pointless GET requests. |
Indeed in our case we have frequently invalidated load functions triggering large computations and this bug causes us trouble, is it expected to be fixed at some point ? Edit : seems like SvelteKit2 solved the issue |
Great to know I am not going crazy! I was flumoxxed about this issue! #11663 |
I can also confirm that upgrading to SvelteKit v2.0 solved the problem for us. |
Careful there are chances you went from a major annoyance bug to an app breaking bug, see #11268 (comment), it's not obvious to see at first. |
The original issue is about The issue some others in this thread have about |
Describe the bug
Hi,
It seems that using a goto() + invalidate() triggers twice an invalidate method which calls twice the load() method from +page.server. This happens only when using custom identifiers as stated by official documentation : https://kit.svelte.dev/docs/modules#$app-navigation-invalidate
GIVEN load() depending on (foo:bar) WHEN goto + invalidate(foo:bar) THEN load method called twice (KO)
GIVEN load() depending on (foo-bar) WHEN goto + invalidate(foo-bar) THEN load method called once (OK)
If I just misunderstood this documentation, please let me know :)
Maybe invalidate + goto should be used together ? But goto doesn't seem to invalidate at every searchParams change (when modyfing existing searchParam value)
Thanks for your work !
Reproduction
Minimal reproduction:
https://stackblitz.com/edit/stackblitz-starters-axljya?file=src%2Froutes%2F%2Bpage.svelte
+page.js
+page.server.js
Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: