Skip to content

Svelte 5: Reactivity bug in REPL #10062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JVariance opened this issue Jan 2, 2024 · 2 comments · Fixed by #10111
Closed

Svelte 5: Reactivity bug in REPL #10062

JVariance opened this issue Jan 2, 2024 · 2 comments · Fixed by #10111
Assignees

Comments

@JVariance
Copy link

Describe the bug

This bug appears only in the REPL. It works locally.

<script>
	let objArray = $state([{a: 1, b:2}, {a: 3, b:4}]);
</script>

<button onclick={() => {objArray = [{a: 8, b:2}, {a: 12, b:4}]}}>
	change
</button>
{#each objArray as c}
	<p>{c.a} - {c.b}</p>
	<input bind:value={c.a}/>
{/each}
  • If I change the input value, the state is updated
  • If I press the change button and afterwards change the input value, the state is also updated
  • BUT If I press the button multiple times and then change the input value, the state is NOT updated anymore

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAACk3OwWrDMBAE0F9Ztj0k4MYk7aGosiHfEecgy5tGqSIJaxUIQv9e5BaS4wzDYzKejKWI4pDRqSuhwH0I2CDfQw3xRpYJG4w-zbo2MurZBO4HN7AlBj9e9vOs7tDBa2TFtDpkJWDbwCh2pYEa3mv4KMf11-Bk-wCcHBOzd-Cdtkb_dHm1hq6H_IQu2ueztt39c6UsL_RZuW-q8p_WDy6_kNLnxzcVQZe6laHPeqMKvEHWm7HINiyGNC4khtG4SdyUTdQts7ZabbUKNnj1kzkZmlDwnKgcyy8nbhi7PgEAAA==

Logs

No response

System Info

Svelte v5.0.0-next.27

Severity

annoyance

@navorite
Copy link
Contributor

navorite commented Jan 4, 2024

Here is a simple reproduction.

This regression happened due to #10053, (the state gets updated, but the <p> effect doesn't). It happens only when doing:

<p>{x.a} - {x.b}</p>

but not when doing:

<p>{x.a}</p>

After debugging, it seems related to consumers in the signal being removed incorrectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants