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

afterNavigate is called for destroyed route if transitions are present #13018

Open
Rich-Harris opened this issue Nov 17, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@Rich-Harris
Copy link
Member

Describe the bug

An afterNavigate callback should only run if the component in question is still active. If a page has an afterNavigate callback and also contains transitions, then the page's effects (including the one responsible for afterNavigate) are not destroyed until after transitions have finished, but the afterNavigate callback will run as soon as the navigation completes.

The result is that the callback might error, since it could refer to data that no longer exists.

To be honest I'm not sure what the correct behaviour is here — obviously we don't want to run the afterNavigate callbacks if we've already navigated away, but that can only happen if effect teardown runs before transitions complete. Which maybe is the correct thing to do, in which case this is a Svelte bug?

Unfortunately I don't have any time to spend on this right now, so will come back to it later

Reproduction

https://github.com/Rich-Harris/kit-after-navigate-timing

Logs

No response

System Info

latest

Severity

annoyance

Additional Information

No response

@Rich-Harris Rich-Harris added the bug Something isn't working label Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant