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

fix(reactivity): re-fix #10114 #10123

Merged
merged 6 commits into from
Jan 18, 2024
Merged

fix(reactivity): re-fix #10114 #10123

merged 6 commits into from
Jan 18, 2024

Conversation

johnsoncodehk
Copy link
Member

@johnsoncodehk johnsoncodehk commented Jan 15, 2024

Re-fix #10114 and resolve #10085 and #10090 regressions introduced in 3.4.14.

Copy link

github-actions bot commented Jan 15, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 89.9 kB (+95 B) 34.3 kB (+58 B) 30.9 kB (+72 B)
vue.global.prod.js 147 kB (+95 B) 53.5 kB (+24 B) 47.8 kB (+46 B)

Usages

Name Size Gzip Brotli
createApp 50.3 kB (+95 B) 19.7 kB (+29 B) 17.9 kB (+38 B)
createSSRApp 53.6 kB (+95 B) 21 kB (+39 B) 19.1 kB (-4 B)
defineCustomElement 52.6 kB (+95 B) 20.4 kB (+40 B) 18.6 kB (+40 B)
overall 64 kB (+95 B) 24.8 kB (+43 B) 22.4 kB (+23 B)

@johnsoncodehk
Copy link
Member Author

/ecosystem-ci run

@vue-bot
Copy link
Contributor

vue-bot commented Jan 15, 2024

📝 Ran ecosystem CI: Open

suite result latest scheduled
language-tools failure failure
nuxt success success
pinia success success
quasar success success
radix-vue success success
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 success
vue-simple-compiler success success

@johnsoncodehk johnsoncodehk marked this pull request as ready for review January 16, 2024 00:09
})
const provider = computed(() => value.value + consumer.value)
expect(provider.value).toBe('0foo')
expect(provider.effect._dirtyLevel).toBe(DirtyLevels.Dirty)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it is good practice to leave a computed dirtyLevel as Dirty after accessing its value.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct and reasonable, because provider deps are indeed changed during accessing its value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's OK, but then we should find a way to triggerEffects even computed are dirty.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it works with the latest commit.

@Doctor-wu
Copy link
Member

<script setup>
import {ref, computed, nextTick, effect} from "vue"
const value = ref(0)
    
const consumer = computed(() => {
    value.value++
    return 'foo'
})
const provider = computed(() => value.value + consumer.value)
effect(() => {
  // should console twice
  console.log(provider.value)
})
nextTick().then(() => {
  value.value += 1
})
</script>

<template>
  <div>
    1
  </div>
</template>

This computed will lose it's reactivity

@johnsoncodehk johnsoncodehk marked this pull request as draft January 16, 2024 02:24
@johnsoncodehk
Copy link
Member Author

/ecosystem-ci run

@vue-bot
Copy link
Contributor

vue-bot commented Jan 16, 2024

📝 Ran ecosystem CI: Open

suite result latest scheduled
language-tools failure failure
nuxt failure success
pinia success success
quasar success success
radix-vue ⏹️ cancelled success
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 success
vue-simple-compiler success success

@johnsoncodehk johnsoncodehk marked this pull request as ready for review January 16, 2024 04:19
@johnsoncodehk
Copy link
Member Author

The latest CI results are here, it was not updated in the comment:

https://github.com/vuejs/ecosystem-ci/actions/runs/7536772812

@yyx990803 yyx990803 merged commit c2b274a into vuejs:main Jan 18, 2024
11 checks passed
@lehni
Copy link
Contributor

lehni commented Jan 21, 2024

@johnsoncodehk I believe I've found your changes here to cause new issues, see #10172

@gjssss
Copy link

gjssss commented Jan 23, 2024

Hey! Here I found a confused problem.

dep.get(effect) === effect._trackId

Here I think it will always be true, because when traversing this dep(map), the key effect's value is effect._trackId which is set in trackEffect

I'm not sure if it has other functions. : >

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.

Reactive fail on 3.4.13
6 participants