-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Copy link
Labels
Description
Describe the bug
View transition completes before the children are mounted leading to transitioning to the same UI before DOM is swapped. This is happening when async functions are awaited during component initilization.
Reproduction
+layout.svelte
onNavigate((navigation) => {
if (!document.startViewTransition || navigation.willUnload) return;
return new Promise((resolve) => {
document.startViewTransition(async () => {
const s = (performance.now());
if (navigation.to?.url) {
await Promise.all([preloadCode(navigation.to.url.pathname), preloadData(navigation.to.url.toString())]);
}
resolve();
console.log('transition resolved', performance.now() - s);
await navigation.complete;
console.log('nav completed', performance.now() - s);
});
});
});
+page.svelte
await new Promise(resolve => setTimeout(resolve, 500));
onMount(() => {
console.log('page ready')
});
I initially reproduced enabling network throttling while awaiting remote functions within component initlization. Note that {#await} works as intended.
Logs
transition resolved 1.399999976158142
+layout.svelte:25 nav completed 3.5
+page.svelte:42 page readySystem Info
System:
OS: macOS 15.5
CPU: (14) arm64 Apple M4 Pro
Memory: 125.22 MB / 24.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.14.0 - /Users/jee/.nvm/versions/node/v22.14.0/bin/node
Yarn: 1.22.22 - /Users/jee/.nvm/versions/node/v22.14.0/bin/yarn
npm: 11.6.1 - /Users/jee/.nvm/versions/node/v22.14.0/bin/npm
bun: 1.2.15 - /Users/jee/.bun/bin/bun
Browsers:
Chrome: 141.0.7390.77
Firefox: 141.0.3
Safari: 18.5
npmPackages:
@sveltejs/adapter-node: ^5.3.2 => 5.3.2
@sveltejs/kit: ^2.46.5 => 2.46.5
@sveltejs/vite-plugin-svelte: ^6.1.4 => 6.2.0
svelte: ^5.39.12 => 5.39.12
vite: ^7.1.9 => 7.1.9Severity
annoyance
Additional Information
No response