You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Describe the bug
An
afterNavigate
callback should only run if the component in question is still active. If a page has anafterNavigate
callback and also contains transitions, then the page's effects (including the one responsible forafterNavigate
) are not destroyed until after transitions have finished, but theafterNavigate
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
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: