-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Describe the bug
I have a route that when it is mounted it modifies some state and immediately redirects using goto
. As result this route does not contain any html, it is purely for redirecting to the next page on the client.
The issue is that the code on the redirect page does not get torn down properly after the redirect, and as result can modify the state even though it is not active.
This only occurs in the built version and not the dev version.
Interestingly it only seems to remain active "once", in that if a store changes for a second time nothing will happen.
Reproduction
https://github.com/OliverHGray/sveltekit-empty-route-issue
To reproduce:
- Clone repo
npm i
npm run build
npm run preview
- Navigate to app
localhost:3000
- (You will immediately be redirected to
page2
) - Click on the button
Expected: Nothing is printed in the console as all page2
does is update the store
Actual: The updated string is printed in the console as the code from the index
route is still active.
Logs
No response
System Info
Don't think this is applicable as this issue happens if I build it locally or on GHA and running on all browsers I've tested it on.
Severity
annoyance
Additional Information
Just an annoyance, as I say adding some dummy content to the page will fix it.
Also would like to say this bug took absolutely forever to find!