Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cold-islands-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: await for `settled` instead of `tick` in navigate
9 changes: 8 additions & 1 deletion packages/kit/src/runtime/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1701,8 +1701,15 @@ async function navigate({

const { activeElement } = document;

const promises = [tick()];

// need to render the DOM before we can scroll to the rendered elements and do focus management
await tick();
// svelte.settled is only available in Svelte 5
if (/** @type {any} */ (svelte).settled) {
promises.push(/** @type {any} */ (svelte).settled());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can svelte.settled() take a long time? After upgrading to v.2.48.0 we suddenly start seeing full-page navigation where we previously saw client-side navigation. It seems like the e.preventDefault() for links is not triggered, so we often end up getting the native full-page navigation instead of sveltekit's client-side navigation.

If i go into our app and wait a little bit, then client-side navigation usually works. But if i go into our app and click on a link within <5-10s of initial load then a full page navigation is triggered.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, i don't know if we're using svelte.settled - where is this defined?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you also upgrade svelte to the latest version?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, we have a different issue with the latest Svelte versions (since 5.41.1, 5.41.0 is the latest working version for us). We're heavily affected by this performance regression: sveltejs/svelte#16990

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the problem, unfortunately...previous svelte versions don't resolve settled 😔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, okay. We're kinda in a deadlock now, we can't upgrade Svelte or Sveltekit with the latest updates :/ With all of these being minor updates it feels kinda scary that there are regressions in performance and behaviour.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @MathiasWP the full-page navigations don't sound normal. Hydration shouldn't be taking that long. Is it possible for you to reproduce this and create an issue for it?

Copy link
Contributor

@MathiasWP MathiasWP Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it was because we used version 5.41.0 of Svelte together with the latest version of SvelteKit that had this PR merged. The bug disappeared in sveltekit after updating svelte with the fix in #17051.

It would be nice in the future to get a heads up if a sveltekit update requires a minimum version of Svelte, this wasn't really communicated anywhere :/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't intentional. We're trying our best

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The minimum version of Svelte should always be the one specified in the peerDependency list of SvelteKit's package.json file. I think the package manager will tell you if it's not within the specified version range.

}
// we still need to await tick everytime because if there's no async work settled resolves immediately
await Promise.all(promises);

// we reset scroll before dealing with focus, to avoid a flash of unscrolled content
let scroll = popped ? popped.scroll : noscroll ? scroll_state() : null;
Expand Down
Loading