`replace` triggers `DOMException`
See original GitHub issueI noticed my browser did weird things when I used the replace function provided by svelte-spa-router. In my case the route was somehow duplicated and I tried to reproduce this with a minimal example in the Svelte Repl.
In the Svelte Repl, when trying to navigate with replace, just a DOMException is thrown. This does not seem to be expected behavior (if I read the documentation correctly):
https://svelte.dev/repl/1321fcda2b774b6e9a13146358ebfcec?version=3.20.1

Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Uncaught (in promise) DOMException: play() failed because ...
I encountered a similar error with while attempting to play an audio file. At first, it was working, then it stopped working when...
Read more >Failed to execute 'replaceState' on 'History': #<Object> could ...
I think the issue is because of trying to push a complex object into the page state. Once I replaced the page state...
Read more >DOMException - Web APIs | MDN
DOMException is a Serializable object, so it can be cloned with structuredClone() or copied between Workers using postMessage() . Constructor.
Read more >Javascript – 'DOMException: Failed to execute 'querySelectorAll' on ...
Javascript – 'DOMException: Failed to execute 'querySelectorAll' on 'Element' when ... selected); // Trigger onchange() event $select.trigger('change'); ...
Read more >failed to execute 'open' on 'xmlhttprequest': invalid url - You.com
I get this error : DOMException: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL. I read I need to replace the port by...
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

What do you mean with “route duplication issue”?
Anyways, thanks for confirming this is an issue with the REPL. I think I can make a code change to detect that scenario and issue a warning in the console, to make the DX a bit better.
All navigation method (
push,pop,replace) already wait for the next tick: https://github.com/ItalyPaleAle/svelte-spa-router/blob/master/Router.svelte#L120So,
await’ing in your code shouldn’t be necessary, unless you are doing some async work yourself…