[NP-6345] Prevent detail views from recursively rendering #1339
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.
It is possible for properties to be recursive, and these properties crash detail views.
For example, the factory for
view
on afoam.nanos.menu.Menu
introduces recursion:What Won't Work
There is a very narrow subset of appropriate solutions to this problem. Here are just a few things that don't work:
data
passed to child views.data
plus theclass
of the view would seem to avoid repetition, but some views may display different information for the samedata
depending on other view properties. (looking at you,SectionView
)The only general solution for all views would then involve detecting whether the
render
function of a view will halt or not. This we know to be impossible, as it is the definition of the Halting Problem.What Did Work
While there's no solution for all views, infinite recursion can be avoided on a subset of views with known behaviour. Providing a convention and tools to handle this will allow anyone to add a view to this subset.
This PR adds a
referencePath
context value.data
to this path.RecursionSafePropertyView
MapView
, and any view we want to be safe from recursion, also checks this pathExample introducing recursion to a property:
Example of detail view for this property: