-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Redirect from +layout.server.ts not running redirected pages onMount #13780
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
Isn't this expected? The I guess you can achieve the expected with |
Yeah i get technically it hasnt unmounted because of SSR smartness but not because of expected behaviour. If I hit the route in the dashboard: /dashboard What you are saying is that any page that gets redirected back to itself from another page will not behave as other redirects do? Which means if I have a case where my dashboard returns the user back to the page they came from, which could be any page in the app... then every page needs $effect just to account for this specific redirect behavior... because redirect has split personalities. This is a problem, a small one and an unlikely one but one that could still cause bugs in apps. In some cases this might actually benefit developers but in my case it is unexpected and the $effect is not an ideal solution, its a patch. I guess that is the tradeoffs of doing the SSR ahead of time and there is not much i can do about this? I dont want to use $effect |
|
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
Short; When redirecting from a page to another page and then back quickly it seems onMount does not run again.
If i have page1 and in does a
goto("/page2")
, and page2 has does a redirect back to page1 like thisredirect(302, "/page1")
then the onMount of page1 does not run again.Im guessing the redirect is so quick that the unmount probably does not fully happen and so a mount does not happen. Im not sure. But it is causing issues for me as explained below and shown in the stackblitz reproduction.
Instructions
Login page does "goto("/dashboard")"
Dashboard does redirect back to the login: /login?redirect="blabla"
Login page onMount does not run
Reproduction
This behaviour can be seen in this reproduction which has clear instructions and UI for ease:
https://stackblitz.com/edit/sveltejs-kit-template-default-guhascda?file=src%2Froutes%2Flogin%2F%2Bpage.svelte
System Info
Severity
serious, but I can work around it
The text was updated successfully, but these errors were encountered: