(wip) track resources in Suspense that are read conditionally behind other resource reads (see #4430) #4444
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.
Currently, Suspense only tracks resources that are read immediately when it is rendered. This can cause issues in more complex components, in which a resource is read conditionally only once another resource reaches
Some(_)(see example in #4430). This is easy to fix in simple situations but becomes increasingly more difficult as applications become more complex and components are nested. This is especially difficult to deal with in real applications because it represents a race condition between the two resources: if the inner one happens to resolve before the inner one, the bug will not occur; whereas if the inner one is still pending when the outer one has resolved, it will.This PR is an attempt to improve that behavior by changing the behavior of Suspense to check its children multiple times, until it finds no further resource reads. This adds some performance overhead in exchange for preventing a number of hydration issues that can be hard to track down.