You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, this change causes our code base to get into a deadlock situation with two components which appear to be awaiting one another's resources, though it's not obvious. Is anyone able to explain more about this fix and what behaviour it affects? We aren't using allowRecurse explicitly anywhere. We're using SFCs and Pinia stores. Pinia stores load in the background and their values are injected into the setup of components which then receive updates via computed properties that depend on storeToRefs() to map the store state to the local component state.
The way that the Pinia stores are loaded in the background is that they return their initial (previously known) state when their computed properties are accessed and as a side-effect they asynchronously fetch from apis and then update their state values. The intention behind our modified stores is that the act of setting a store state value would mark a computed property as dirty and recompute it as needed. We are depending on Vue to allow side-effects, or more specifically to regard any side-effects such as asynchronous closures as non-dirty.
As far as I can tell we have built our stores to look similar to the new test case it should work when chained(ref+computed) previously returning a not dirty flag (since we took advantage of the fact vue doesn't care about computed side-effects), whereas now with this change it returns dirty. Would the way to implement something like this now be to make a customRef which does the asynchronous wait (and lock), and can return its value but not trigger - until the async call returns at which point it sets the value again and calls trigger()
EDIT: For those reading this later, I solved the above problem by following this pattern (can be added to Computed.spec.ts):
it('should be able to cause ignorant developer side-effects', async () => {
let val: number = 1
const v = customRef<number>((_track, trigger) => ({
get: (): number => {
// in a real-world app this would be an api call or similar
setTimeout(() => {
v.value = 2
trigger()
}, 10)
return val
},
set: (value: number) => {
val = value
trigger()
},
}))
const sideEffectWatcher = computed(() => v.value)
expect(v.value).toBe(1)
await new Promise((resolve) => {
setTimeout(() => resolve(true), 15)
})
expect(v.value).toBe(2)
expect(sideEffectWatcher.effect._dirtyLevel).toBe(DirtyLevels.Dirty)
})
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This resolves the regression introduced by #10091 and re-fix #10082.
Also fix a test of #10085, #10090.