Skip to content
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

Recursive sync watcher stops tracking computed #12033

Closed
skirtles-code opened this issue Sep 25, 2024 · 0 comments
Closed

Recursive sync watcher stops tracking computed #12033

skirtles-code opened this issue Sep 25, 2024 · 0 comments
Labels
❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. regression scope: reactivity

Comments

@skirtles-code
Copy link
Contributor

Vue version

3.5.6

Link to minimal reproduction

https://play.vuejs.org/#eNp9Uctqw0AM/BWxlzjgOC19QXBCH4TSHtrS9rhQ3I2cOFnvmn04KcH/Xq2N0xxKbtLMSMxIe3ZXVUntkU1YaoUpKgcWna9mXBVlpY2DPRjMY9hmTqxiELqsvMMFNJAbXcKAZgdccSW0sg4MTIM8Ohv2iCCkH4qiIUxnYJI6kx5JwlW7NhIxRHXL7bkCKHJqYQbnw66HfmQ0Cm3DVROTr1x6u5rAwP4oMYCG9qXjLgO5p8ZhWcnMIXUAe8oBTQOjUIlQpd/eOa3gVshCbKacBfM3nM0edTruOJpMx0drWMycpVx5sUzWViu6WmuQsxCxkGheK1dQbs4mvXXOMin19rnFnPEY97hYodj8g6/tLmCcvRm0aGrk7MC5zCzRdfT84wV3VB/IUi+8JPUJ8h2tlj547GT3Xi3I9pGudfvU/r5Qy0873zlUtg8VjLY/aPWc0fsfTkT/s3uRXPa/oyt+1WjCTjrgRXKVXLPmFzJo0y8=

Steps to reproduce

Just click the button.

What is expected?

The rendered values should be 1.

What is actually happening?

The rendered values are 6.

System Info

No response

Any additional comments?

This changed in 3.5.6. In 3.5.5 and earlier it renders 1, as expected.

I found this while investigating #11956. I still don't know what causes the memory leak, but after staring at #11944 for a bit I noticed the potential problem I've reported here.

This is what I believe is happening...

When a computed is notified, the NOTIFIED flag gets set for both ComputedRefImpl and its dep. These are queued in a batch. When endBatch() is called it handles the dep first, clearing the NOTIFIED flag from the dep and then calling trigger(). But the NOTIFIED flag is still set for the ComputedRefImpl, so it can't be notified while trigger() is running.

I used watch with flush: 'sync' in the reproduction, as that was the most direct way to take advantage of the mismatched flags. I'm not sure whether there's a more 'normal' way to hit this timing issue.

@edison1105 edison1105 added scope: reactivity ❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. regression labels Sep 26, 2024
yangxiuxiu1115 pushed a commit to yangxiuxiu1115/core that referenced this issue Sep 26, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Oct 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. regression scope: reactivity
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants