Skip to content

Adding a property to a reactive object within a v-for loop cause error: Maximum recursive updates exceeded in component in the development environment #11807

Closed
@heggria

Description

@heggria

Vue version

3.5.0

Link to minimal reproduction

https://play.vuejs.org/#eNp9kk1PwzAMhv+KlQutVDrE16G0Q4A4gMSHgBtBqGu9EWiTKknLUNX/jtMpY0jTDpUsv4/d1457dtE0cdciS1hqCi0aCwZt20y5FHWjtIUeNM4jUPJOtdJiCQPMtaphj6r2zrjkslDSWFCNFRRA5vjg9S3kcl0TBGE27bkET8VdXrVI7IXW+U/sGgY9VCgX9iOBw1MYIghCyKYQ9ENIrQb60snKIXlLLdZNlVukGCAtRQfd/lzpjLNAkBaBCEFI/zvOIPnCH1IFZ2MJQN+DI+Mczn2Q+CADAcPwn5t5bua52Vau8FzhuWIrV3qu9Fy5waUTmskNOtmYlEXMGtr2XCziT6MkPdq4VM4KVTeiQv3g501gVJyWV5X6vh1zVrcY+XzxgcXXlvynWbocZ48aDeoOOVtrNtcLtCv5+vkelxSvxVqVbUX0DvEJjapa53GFXbayJNsb3Oj2Zjw9IRcv5nppURo/lDPqyGHkOaMbvNox+p/do/h4rKNLoi2+d6hdT1rgUXwSH7DhF/tZ+sE=

Steps to reproduce

The error occurs immediately.
P.S.: This bug can be triggered if the total number of updates to a reactive object within a v-for exceeds 100.The following code patterns will all trigger the error.

<script setup>
import { ref, onMounted } from 'vue';

const options = ref([])
onMounted(()=>{
  options.value = Array.from({ length: 34 }, () => ({}))
})
</script>
<template>
  <div v-for="(item, i) in options" :key="i">
    {{ item.a ? item.a : item.a = i }}
    {{ item.b ? item.b : item.b = i }}
    {{ item.c ? item.c : item.c = i }}
  </div>
</template>
<script setup>
import { ref, onMounted } from 'vue';

const options = ref([])
onMounted(()=>{
  options.value = Array.from({ length: 21 }, () => ({}))
})
</script>
<template>
  <div v-for="(item, i) in options" :key="i">
    {{ item.a ? item.a : item.a = i }}
    {{ item.b ? item.b : item.b = i }}
    {{ item.c ? item.c : item.c = i }}
    {{ item.d ? item.d : item.d = i }}
    {{ item.e ? item.e : item.e = i }}
  </div>
</template>

What is expected?

This issue does not occur in version 3.4.38. The goal is to prevent the error from occurring again.

What is actually happening?

It’s not confirmed, but I suspect there’s an error in the flushJobs function of runtime-core related to the calculation of count.

System Info

No response

Any additional comments?

In my local development environment, this error causes certain components that work in 3.4.38 (such as those using options in a select) to become unusable, leading to rendering issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions