kit
kit copied to clipboard
Calling a command inside an effect causes an infinite loop
Describe the bug
The following triggers an infinite loop where pending_count is constantly updated.
<script>
import { mark_seen } from '$lib/foo.remote.ts';
const { params } = $props();
$effect(() => {
$inspect.trace('mark');
mark_seen(params.id);
});
</script>
Reproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-piu37bpc?file=src%2Froutes%2F%2Bpage.svelte
Logs
$state pending_count 1
$state pending_count 2
$state pending_count 3
... etc
Severity
serious, but I can work around it