Skip to content

feat(reactivity): computed side effects no longer trigger scheduler#10232

Merged
yyx990803 merged 14 commits into
vuejs:mainfrom
johnsoncodehk:workaround-for-10214
Feb 6, 2024
Merged

feat(reactivity): computed side effects no longer trigger scheduler#10232
yyx990803 merged 14 commits into
vuejs:mainfrom
johnsoncodehk:workaround-for-10214

Conversation

@johnsoncodehk

@johnsoncodehk johnsoncodehk commented Jan 29, 2024

Copy link
Copy Markdown
Member

close #10214

This PR introduces a special state MaybeDirty_ComputedSideEffect to avoid computed side effects triggering effect/watch/render callbacks.

Although this workaround is to solve the regressions introduced by the new Reactivity System, I think this is not the accurate behavior. The reproduction of #10214 (and related issues) should indeed cause an infinite loop. I recommend throwing a warning for the case where computed produces side effects. And remove the MaybeDirty_ComputedSideEffect workaround in 3.5.

Blocking by #10187

@github-actions

github-actions Bot commented Jan 29, 2024

Copy link
Copy Markdown

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 90.2 kB (+86 B) 34.3 kB (+34 B) 31 kB (+34 B)
vue.global.prod.js 147 kB (+86 B) 53.6 kB (+28 B) 47.9 kB (-36 B)

Usages

Name Size Gzip Brotli
createApp 50.4 kB (+82 B) 19.7 kB (+26 B) 18 kB (-15 B)
createSSRApp 53.7 kB (+82 B) 21 kB (+29 B) 19.2 kB (+27 B)
defineCustomElement 52.7 kB (+82 B) 20.4 kB (+27 B) 18.7 kB (+38 B)
overall 64.1 kB (+86 B) 24.8 kB (+22 B) 22.4 kB (+19 B)

@johnsoncodehk

Copy link
Copy Markdown
Member Author

/ecosystem-ci run

@johnsoncodehk johnsoncodehk changed the title feat(reactivity): recurse computed effect no longer triggers schedulers feat(reactivity): computed side effects no longer trigger scheduler Jan 29, 2024
@vue-bot

vue-bot commented Jan 29, 2024

Copy link
Copy Markdown
Contributor

📝 Ran ecosystem CI: Open

suite result latest scheduled
language-tools success success
nuxt success failure
pinia success success
quasar success failure
radix-vue success failure
router success success
test-utils success success
vant success success
vite-plugin-vue success success
vitepress success success
vue-i18n success success
vue-macros success success
vuetify success success
vueuse success failure
vue-simple-compiler success success

@Doctor-wu

Copy link
Copy Markdown
Member

Highly agree with warning users when computed keep dirty after run effect.

@yyx990803 yyx990803 marked this pull request as ready for review February 6, 2024 10:34
@yyx990803

Copy link
Copy Markdown
Member

I agree such cases should definitely throw warnings, whether we can remove it in the next minor is questionable, as such misuse seems to be prevalent in userland, especially Vue 2 codebases migrating to Vue 3.

@yyx990803 yyx990803 merged commit 0bced13 into vuejs:main Feb 6, 2024
n0099 added a commit to n0099/open-tbm that referenced this pull request Feb 9, 2024
…eir assumed fix vuejs/core#10232

$ yarn remove {,@types}lodash
$ yarn add {,@types}lodash-es
* move packages `@tanstack/{eslint-plugin-query,vue-query-devtools}` & `@types/lodash-es` to `devDependencies` section @ package.json
@ fe
@Doctor-wu

Copy link
Copy Markdown
Member

I committed a PR for warning users stuff

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 this pull request may close these issues.

Maximum recursive updates exceeded in component in 3.4.15

4 participants