-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Labels
Description
Describe the bug
$inspect
can somehow cause a $derived
to operate on data
belonging to the next page when navigating. When the $inspect
is removed, the problem disappears.
Reproduction
Code
// /some-route/+page.server.js
export function load() {
return {
items: [
{ id: 1, name: 'Item 1' },
{ id: 2, name: 'Item 2' },
{ id: 3, name: 'Item 3' },
{ id: 4, name: 'Item 4' },
{ id: 5, name: 'Item 5' },
],
};
}
<!-- /some-route/+page.svelte -->
<script lang="ts">
import List from './list.svelte';
let { data } = $props();
const { items } = $derived(data);
const even = $derived(items.filter((item) => item.id % 2 === 0));
</script>
<List items={even} />
<!-- /some-route/list.svelte -->
<script lang="ts">
const { items } = $props();
$inspect(items); // <- remove this
</script>
{#each items as item}
<div>
<a href="/">{item.id}</a>
</div>
{/each}
Logs
+page.svelte:13 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'filter')
in <unknown>
in layout.svelte
in root.svelte
at +page.svelte:13:49
at update_reaction (chunk-DJJYHU3C.js?v=ad8341b0:2754:23)
at execute_derived (chunk-DJJYHU3C.js?v=ad8341b0:1240:15)
at update_derived (chunk-DJJYHU3C.js?v=ad8341b0:1257:15)
at is_dirty (chunk-DJJYHU3C.js?v=ad8341b0:2681:11)
at flush_inspect_effects (chunk-DJJYHU3C.js?v=ad8341b0:1398:9)
at internal_set (chunk-DJJYHU3C.js?v=ad8341b0:1386:7)
at set (chunk-DJJYHU3C.js?v=ad8341b0:1337:10)
at Object.set (chunk-SRUB5KV5.js?v=ad8341b0:829:11)
at Object.assign (<anonymous>)
System Info
(StackBlitz)
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: 20.19.1 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.8.2 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
@sveltejs/adapter-auto: ^6.0.0 => 6.0.1
@sveltejs/kit: ^2.22.0 => 2.25.1
@sveltejs/vite-plugin-svelte: ^6.0.0 => 6.1.0
svelte: ^5.25.0 => 5.36.13
vite: ^7.0.4 => 7.0.5
Severity
annoyance
Additional Information
This seems like more of a Svelte issue, but I was unable to create a clean reproduction showing the difference between having the $inspect
and not having it without SvelteKit.