[BUGFIX release] Don’t force invalidation of block param streams #11570
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 commit removes the forced invalidation of block param streams on re-renders.
Previously, on re-renders, all block param streams were revalidated by calling
notify()
on them blindly.While this often works, it creates a vector for light scopes to inadvertently invalidate their associated shadow scopes. In some cases, this leads to an infinite loop.
For example, imagine a component with the following template:
(Here
danger
is a property on the component.)Now we invoke it:
This works. The yielded block (light scope) receives a stream for the
danger
value. On re-renders, the stream is invalidated, but all that happens is the{{dangerBlockParam}}
render node is dirtied again (which doesn’t matter, because we haven’t rendered and cleaned it yet).However, imagine we change the component template to now display the same
{{danger}}
value:Now, when the block param stream is invalidated, it goes back and dirties the render node from the parent shadow scope. Because the component is dirtied, its
{{yield}}
helper is dirtied, causing the block param streams to be dirtied, and so on in an infinite loop.This commit removes the forced invalidation, which I believe is unnecessary and probably left over from an earlier implementation. Specifically, if we are yielded a stream (
{{yield danger}}
), the stream should notify us of any changes to the value. Any downstream consumers of that stream will be notified correctly.In the case of
{{yield “hello”}}
or some other primitive, we already wrap those values in aProxyStream
and callsetSource
when it changes, which has the effect of invalidating the stream anyway.Closes #11519