Skip to content

Svelte 5: $inspect make $effect run syncronously #13237

Closed
@paoloricciuti

Description

@paoloricciuti

Describe the bug

If you add an $inspect that is listening on a variable that is also listening on an $effect the $effect is run syncronously instead of the next microtask.

<script>
	let count = $state(0);

	function increment() {
		count += 1;
		console.log("in-increment", count);
	}

	$effect(() => {
		console.log("effect", count);
	});
	
	$inspect(count);
</script>

<button onclick={increment}>
	clicks: {count}
</button>

on click it will log

effect 1
update 1
in-increment 1

Reproduction

REPL

Logs

No response

System Info

repl

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions