-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
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 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.
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:
- This is a standard Sveltekit project. Install deps, run
pnpm dev, and load the site. - Click the "Go to page" link. The route that this loads intentionally delays the
loadfunction by 5 seconds. - While it's loading, click "Go to page" again and see that it navigates to a nonexistent route.
Logs
No response
System Info
System:
OS: macOS 12.0.1
CPU: (10) arm64 Apple M1 Pro
Memory: 1.37 GB / 32.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.13.0 - /opt/homebrew/Cellar/node@16/16.13.0/bin/node
Yarn: 1.22.17 - /opt/homebrew/Cellar/node@16/16.13.0/bin/yarn
npm: 8.1.0 - /opt/homebrew/Cellar/node@16/16.13.0/bin/npm
Browsers:
Brave Browser: 96.1.32.106
Safari: 15.1
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.3
@sveltejs/kit: next => 1.0.0-next.201
svelte: ^3.44.0 => 3.44.2Severity
blocking an upgrade
Additional Information
No response