When PPR is off, app router prefetches will render the component tree up until it encounters a loading segment, at which point it'll just return some metadata about the segment and won't do any further rendering. This is an optimization to ensure prefetches are lightweight and don't potentially invoke expensive dynamic subtrees. However, there's a bug in this logic that is causing it to bail unexpectedly even if a segment deeper in the tree contained a loading.js file.
This would mean the loading state wouldn't be triggered until the second request for the full RSC data is initiated, resulting in an unintended delta between when a link is clicked and the loading state is shown.
Why
The shouldSkipComponentTree flag was incorrectly being set to true even if the loading.js segment appeared deeper in the tree. Prefetch requests from the client will always contain FlightRouterState, so the logic to check for loading deeper in the tree will always be missed.
How
This removes the flightRouterState check as it doesn't make sense: prefetches will currently always include the flightRouterState, causing this to always short-circuit. I believe that this check is vestigial from when we were generating static prefetch.rsc outputs which is no longer the case.
This mirrors a similar check when determining if parallel route(s) should be rendered.
What
When PPR is off, app router prefetches will render the component tree up until it encounters a
loading
segment, at which point it'll just return some metadata about the segment and won't do any further rendering. This is an optimization to ensure prefetches are lightweight and don't potentially invoke expensive dynamic subtrees. However, there's a bug in this logic that is causing it to bail unexpectedly even if a segment deeper in the tree contained aloading.js
file.This would mean the loading state wouldn't be triggered until the second request for the full RSC data is initiated, resulting in an unintended delta between when a link is clicked and the loading state is shown.
Why
The
shouldSkipComponentTree
flag was incorrectly being set totrue
even if theloading.js
segment appeared deeper in the tree. Prefetch requests from the client will always containFlightRouterState
, so the logic to check for loading deeper in the tree will always be missed.How
This removes the
flightRouterState
check as it doesn't make sense: prefetches will currently always include theflightRouterState
, causing this to always short-circuit. I believe that this check is vestigial from when we were generating staticprefetch.rsc
outputs which is no longer the case.This mirrors a similar check when determining if parallel route(s) should be rendered.