-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Invalidate all + redirects not working as expected. #6844
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
Comments
(going off of the log above) I think whats happening here is... After the invalidation is completed, we are redirected to I think the expected behavior here is, in order to load If the route isn't re-loaded from the root layout, we won't know there was a change when we get the data from Current: ...
/+layout | onboarded-id
/+page | onboarded-id
/+page | redirecting to /onboarded-home
/(student)/(onboarded)/+layout | not-onboarded-id <------ should be `onboarded-id`
/+(student)/(onboarded)/+layout | redirecting to /
/+page | not-onboarded-id <------ should be `onboarded-id`
/+page | redirecting to /signup
/+layout | onboarded-id
REDIRECT LOOP error :( Expected? ...
/+layout | onboarded-id
/+page | onboarded-id
/+page | redirecting to /onboarded-home
+/+layout | onboarded-id
+/(student)/+layout | onboarded-id
-/(student)/(onboarded)/+layout | not-onboarded-id <------ should be `onboarded-id`
+/(student)/(onboarded)/+layout | onboarded-id
-/+(student)/(onboarded)/+layout | redirecting to /
-/+page | not-onboarded-id <------ should be `onboarded-id`
-/+page | redirecting to /signup
-/+layout | onboarded-id
-REDIRECT LOOP error :(
+You are at onboarded home! |
ok i encountered this issue elsewhere again. I think the problem is |
I ran across something similar. It took me a while to figure out what was going on. You may be seeing the same thing. My issue is that when the invalidateAll runs, and loads start re-firing, throwing a redirect in one of them is like throwing an error; which I suspect interrupts the remaining load functions from re-firing or completing. Therefore no updated info in those areas. Just the nature of throwing a redirect using sveltekit's method. |
@j4w8n I also think it has to do with "redirects" being a |
* [fix] tighten up navigation and invalidation logic - Fixes #6844, invalidation is now only reset after navigation settled - Fixes #5305, newer invalidations are no longer swalloed by ongoing older ones - Fixes #6902, the pending prefetch is reset upon invalidation * fix redirect token logic * batch synchronous invalidations * tests * tweak load cache timing and reduce code a little * Apply suggestions from code review Co-authored-by: Rich Harris <[email protected]> * lint Co-authored-by: Rich Harris <[email protected]> Co-authored-by: Rich Harris <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
discord thread: https://discord.com/channels/457912077277855764/1020064864066093196
Hey all - I think i ran into a bug or unexpected behavior that i can't wrap my head around.
The app is structured so that the root
/
acts as a central "router" to determine current user's state and redirect them to appropriate landing pages.The child pages also have their own redirection logic, and if user somehow got to the page directly, user is redirected back to the router
/
.There is a notion of "profiles" and user can switch between the profiles using a switcher component (think AWS, switching between profiles with different permissions).
This component should
set the profile id in cookie from client side
=>invalidate/rerender the current page (client sided, via invalidateAll())
=>if the current page has any redirection logic, redirect with new profile; if page can render with new profile, render with new data, etc.
The problem I am running into is, I call
invalidateAll()
, invalidation/rerunning nested layout code runs as expected (with the new profile id value), but at the very end of redirects, theprofile id
is seen as the previous value (which causes the "redirect loop" error, even when there really isn't a loop).Reproduction
https://github.com/smblee/sveltekit-invalidate-all-bug
I reproduced it as close to my current repo as possible.
Say there are the following pages
/
(router, doesn't actually render),notset
(ONLY when no profile set),signup
(ONLY when profile is not-onboarded),onboarded-home
(ONLY when profile is onboarded).try going from
Set not onboarded profile
=>Set onboarded profile
or the other way around. (it will always fail on the first try, in one direction).you will fail with the following log trace: (
it can seem a bit overwhelming, but it's pretty simple. I basically logged the location and current profile id value at that time in code. and any redirection that happens)
Logs
No response
System Info
Severity
blocking an upgrade
Additional Information
No response
The text was updated successfully, but these errors were encountered: