rsnext/test/e2e/app-dir/app-prefetch
Zack Tanner 2fbdac6f82
fix prefetch bailout detection for nested loading segments (#67358)
### 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 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](b87d8fc499/packages/next/src/server/app-render/create-component-tree.tsx (L393))
when determining if parallel route(s) should be rendered.
2024-07-01 16:11:09 -07:00
..
app fix prefetch bailout detection for nested loading segments (#67358) 2024-07-01 16:11:09 -07:00
prefetching.stale-times.test.ts [Breaking] disable client router cache for page segments (#66039) 2024-05-21 13:54:23 -07:00
prefetching.test.ts fix prefetch bailout detection for nested loading segments (#67358) 2024-07-01 16:11:09 -07:00