clicking hash link recorded in history twice
See original GitHub issueDescribe the bug
When opening #anchor-a
then click a link to #anchor-b
, history newly records entries #anchor-a
and #anchor-b
though #anchor-a
is previous location.
Therefore, hisotry looks like:
#anchor-a (initial view)
#anchor-b
#anchor-b (when clicked #anchor-b)
#anchor-c
#anchor-c (when clicked #anchor-c)
#anchor-d
#anchor-d (when clicked #anchor-d)
...
Disabling router
by export const router = false;
mitigate this issue, so that I think router has some issue around this.
Reproduction
https://stackblitz.com/edit/sveltekit-ivmzya?devtoolsheight=33&file=src/routes/index.svelte
Easily understand by following steps:
Open in New Window
in Stackblitz- Clicking anchor links some times
- Check a browser history, looks like:

(Also I notified null
is oddly appealing on first clicking #anchor-b
)
Logs
No response
System Info
# npx envinfo --system --binaries --browsers --npmPackages "{svelte,@sveltejs/*,vite}"
System:
OS: macOS 11.4
CPU: (8) x64 Apple M1
Memory: 24.88 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.13.2 - ~/.nodebrew/current/bin/node
Yarn: 1.22.17 - ~/.nodebrew/current/bin/yarn
npm: 8.1.2 - ~/.nodebrew/current/bin/npm
Browsers:
Firefox: 95.0
Safari: 14.1.1
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.17
@sveltejs/kit: next => 1.0.0-next.251
svelte: ^3.46.3 => 3.46.3
### Severity
blocking an upgrade
### Additional Information
_No response_
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
What could be causing a duplicate URL hash in history?
The page loads, during the construction of the app, the hash gets set programatically with dojo/hash twice, first time to "", second time...
Read more >#GTMtips: Track URL Fragments As Pageviews | Simo ...
How to track dynamic changes to the page URL, especially URL fragments, as individual page views in Google Analytics.
Read more >Pushing and Popping with the History API - HTML5 Doctor
If one of the hash URLs is used by a modern browser, it uses replaceState to quietly correct the URL.
Read more >HTML5 History: Clean URLs for Deep-linking Ajax Applications
The problem of deep-linking Ajax applications is usually solved by updating the hash value of the URL. This works nicely because the URL...
Read more >Blockchain - Wikipedia
A blockchain is a type of distributed ledger technology (DLT) that consists of growing lists of records, called blocks, that are securely linked...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yeah it does look like that this issue causes #3621. cc @vicky1999 in case you’re already working on a fix.
This was fixed recently. The test has now been uncommented and passes:
https://github.com/sveltejs/kit/blob/a37f3b3de07304641cdae5d3686bfda6861b4489/packages/kit/test/apps/basics/test/test.js#L217