- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 4.7k
Closed
Description
(Poorly) describe the bug
I'm getting all sorts of unexpected errors when mutating state via promises. They only happen in very specific circumstances, and magically vanish when making the slightest change.
Note that these errors arise in 5.0.0-next.18 and later only - works without issues in 5.0.0-next.17 and earlier
Reproduction
REPL
App.svelte
<script lang="ts">
  import Component1 from './Component1.svelte'
  let text = $state()
  $effect(async () => {
    // res.text() works fine
    // text = await fetch('https://jsonplaceholder.typicode.com/todos/1').then((res) => res.text())
    // res.json() causes ERR_SVELTE_UNSAFE_MUTATION
    text = await fetch('https://jsonplaceholder.typicode.com/todos/1').then((res) => res.json())
  })
</script>
{#if text}
  {text}  <!-- this works without issues -->
  <Component1 {text} />  <!-- this causes ERR_SVELTE_UNSAFE_MUTATION -->
{/if}
Component1.svelte
<script>
  import Component2 from './Component2.svelte'
  let { text } = $props()
  function render(text) {
    return text
  }
</script>
<!-- uncommenting the below line causes Error: 'getOwnPropertyDescriptor' on proxy: trap returned descriptor for property 'Symbol(readonly)' that is incompatible with the existing property in the proxy target -->
<!-- {render(text)} -->
<Component2 text={render(text)} />Component2.svelte
<script>
  let { text } = $props()
</script>
{text}Logs
No response
System Info
N/ASeverity
blocking an upgrade
Metadata
Metadata
Assignees
Labels
No labels