Skip to content
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

Route with no content is not torn down properly on navigation #2302

Closed
OliverHGray opened this issue Aug 26, 2021 · 2 comments
Closed

Route with no content is not torn down properly on navigation #2302

OliverHGray opened this issue Aug 26, 2021 · 2 comments
Labels
p3-edge-case SvelteKit cannot be used in an uncommon way

Comments

@OliverHGray
Copy link

OliverHGray commented Aug 26, 2021

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:

  1. Clone repo
  2. npm i
  3. npm run build
  4. npm run preview
  5. Navigate to app localhost:3000
  6. (You will immediately be redirected to page2)
  7. 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!

@benmccann benmccann added the p3-edge-case SvelteKit cannot be used in an uncommon way label Aug 26, 2021
@Rich-Harris
Copy link
Member

Man, this was a good old-fashioned bug hunt the likes of which I haven't been on for a while. Turns out it's a bug in Svelte itself — I've opened an issue over there, so we can close this one. Thanks! sveltejs/svelte#7488

@rmunn
Copy link
Contributor

rmunn commented Jul 10, 2022

The fix for this has been released in Svelte 3.49.0. So @OliverHGray, if you update your project to Svelte 3.49.0 you should see the issue go away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-edge-case SvelteKit cannot be used in an uncommon way
Projects
None yet
Development

No branches or pull requests

4 participants