Skip to content

markup async func run before effect.pre #16694

@sunflower-knight

Description

@sunflower-knight

Describe the bug

REPL

As you can see , when i change count1 , async function (even without proimse )called in markup with await run before effect.pre

Reproduction

<script>
	  import { tick } from 'svelte';
	
  // 定义多个状态变量
  let count1 = $state(0);

 $effect.pre(() => {
    count1 ;
		console.log('Effect pre')});
  $effect(() => {
    count1 ;
		console.log('Effect')
		return ()=>{console.log('tear down');	}
  });
	//zero run before effect pre 
  async function zero(num) {
    console.log(`zero begin`);
    return 0;
  }
 function one(num) {
    console.log(`one begin`);
    return 1;
  }
</script>

<p>count 1: {count1}</p>

<button onclick={()=>{count1+=1 } }>count1++</button>

<div>
<p>zero : {await zero(count1)}</p>	
</div>

<div>
<p>one : {one(count1)}</p>	
</div>

Logs

zero begin
Effect pre
one begin
tear down
Effect

System Info

playground

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions