kit icon indicating copy to clipboard operation
kit copied to clipboard

Calling a command inside an effect causes an infinite loop

Open ottomated opened this issue 2 months ago • 0 comments

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

ottomated avatar Oct 05 '25 01:10 ottomated