kit
kit copied to clipboard
pushState and replaceState throw error in onMount
Describe the bug
Using pushState
or replaceState
in onMount
throws Uncaught (in promise) TypeError: root is undefined
.
(See reproduction)
Reproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-1gpvuv?file=src%2Froutes%2F%5B%5Bparam%5D%5D%2F%2Bpage.svelte
Logs
No response
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 18.18.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 9.4.2 - /usr/local/bin/npm
pnpm: 8.10.5 - /usr/local/bin/pnpm
npmPackages:
@sveltejs/adapter-auto: ^3.0.0 => 3.0.1
@sveltejs/kit: ^2.0.0 => 2.0.6
@sveltejs/vite-plugin-svelte: ^3.0.0 => 3.0.1
svelte: ^4.2.7 => 4.2.8
vite: ^5.0.3 => 5.0.10
Severity
serious, but I can work around it
Additional Information
If you await a tick
before using the methods everything works fine
onMount(async () => {
await tick()
replaceState('', {
...data
});
})
looks to have been reported in https://github.com/sveltejs/kit/issues/11492 and https://github.com/sveltejs/kit/issues/11523 as well