-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe the bug
The server_fallback method from here:
kit/packages/kit/src/runtime/client/client.js
Lines 1122 to 1134 in 74798e9
| async function server_fallback(url, route, error, status) { | |
| if (url.origin === location.origin && url.pathname === location.pathname && !hydrated) { | |
| // We would reload the same page we're currently on, which isn't hydrated, | |
| // which means no SSR, which means we would end up in an endless loop | |
| return await load_root_error_page({ | |
| status, | |
| error, | |
| url, | |
| route | |
| }); | |
| } | |
| return await native_navigation(url); | |
| } |
appears to check if the page has hydrated to prevent infinite reloads when a 404 happens.
However, it seems if invalidate is called (for instance in a +layout.svelte component that is parent to the 404-d page), it is my understanding that invalidate waits for the page to hydrate prior to server_fallback being called, and so an infinite redirect loop appears.
Reproduction
Here's a modified template:
The only change is in the root +layout.svelte where the following has been added:
onMount(() => {
void invalidate('placeholder:identifier')
})Navigating to a non-existing route like /invalid-link (added to the Header navigation for convenience) will trigger an infinite loop of reloads.
Logs
No response
System Info
System:
OS: Linux 5.15 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
CPU: (8) arm64 unknown
Memory: 931.27 MB / 6.77 GB
Container: Yes
Shell: 5.1.4 - /bin/bash
Binaries:
Node: 18.12.1 - /usr/local/bin/node
npm: 8.19.2 - /usr/local/bin/npm
npmPackages:
@sveltejs/adapter-node: ^1.1.4 => 1.1.4
@sveltejs/kit: ^1.2.6 => 1.2.6
svelte: ^3.55.1 => 3.55.1
vite: ^4.0.4 => 4.0.4Severity
serious, but I can work around it
Additional Information
No response