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
When a route is loading and the load is taking a while, clicking another link resolves the href against the destination page's URL instead of the current page, causing the navigation to go to the wrong place.
Say you have a page with this link: <a href="subdir/post">Go to page</a>, and the load function takes a while to resolve. Clicking it once will correctly navigate to /subdir/post, but if you click the link again while it's loading the router will try to access /subdir/subdir/post and encounter a 404 error.
Somewhat related to #2870, although the current stance is to not wait on changing the URL, so the solution to this is then probably independent of #2870
Didn't notice this at first, but also notably, once you reproduce the problem, you end up with three history entries:
/
/subdir/post
/subdir/subdir/post
That feels wrong since technically the user never sees page 2. Even without this bug you would see something like this (in a scenario where the second link clicked is different from the first):
/
/subdir/post
/subdir/otherpost
So as part of this fix I wonder if it would be more correct to use replaceState instead of pushState if navigating during loading.
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
When a route is loading and the load is taking a while, clicking another link resolves the href against the destination page's URL instead of the current page, causing the navigation to go to the wrong place.
Say you have a page with this link:
<a href="subdir/post">Go to page</a>
, and theload
function takes a while to resolve. Clicking it once will correctly navigate to/subdir/post
, but if you click the link again while it's loading the router will try to access/subdir/subdir/post
and encounter a 404 error.Reproduction
I first encountered this on my own personal website when on a very slow internet connection, but I have a minimal reproduction at https://github.com/dimfeld/sveltekit-routing-double-click
Steps:
pnpm dev
, and load the site.load
function by 5 seconds.Logs
No response
System Info
Severity
blocking an upgrade
Additional Information
No response
The text was updated successfully, but these errors were encountered: