[metadata]: ensure metadata boundary is only rendered once on client nav (#76692)
On client navigations, rendering does not start at the root, it starts at the common layout down. As a result the existing heuristic to only render the `<StreamingMetadata />` component once won't work, as `children` will likely appear for parallel routes within the subtree. (In other words: `children` is only useful as a heuristic for root renders). As a result, metadata will get duplicated on client navigation if parallel routes match that page (this is because we iterate over all parallel routes, and conditionally render `<StreamingMetadata />` based on the flawed heuristic above) Since the metadata tree is accumulated and only rendered once, ideally it should never be rendered in `createComponentTree`. Or if it is, we need to ensure it’s never rendered more than once, as it would contain the same contents twice. This PR: - On client navs, ensures that we only render `<StreamingMetadata />` once as part of the `rscHead`, rather than per parallel route segment: [5e3686a](https://github.com/vercel/next.js/pull/76692/commits/5e3686ac55c0020ab843e8a2648f180ad9f33ca6) - On the client, we make sure to prioritize the `head` node corresponding with the root page slot ("children"). Otherwise we might not render `<StreamingMetadata />` at all, since the current heuristic would have early-returned for a parallel route that _didn't_ change as part of the navigation (eg the case where a slot doesn't match, and keeps rendering the previous node): [7364e6e](https://github.com/vercel/next.js/pull/76692/commits/7364e6e008dfb99b454267ff6a7b4a080a9f3d08)
Showing
Please
register
or
sign in
to comment