Skip to content

Commit d3a2971

Browse files
authored
Turbopack: fix graph layout segment optimization (#77094)
The modules in the last layout segment (`server_component_entries`) were visited twice: as part of the last iteration of the for loop (which doesn't propagate its `visited_modules` because it's not a layout), and then again with `rsc_entry`. We already do the right thing in another place: https://github.com/vercel/next.js/blob/f42739d114695702922dab4c08d6c8223daafceb/crates/next-api/src/app.rs#L1740-L1748 Before: ![Bildschirmfoto 2025-03-17 um 11 39 41](https://github.com/user-attachments/assets/62adad85-043c-47f4-8c70-a8f5779e34a9) After: ![Bildschirmfoto 2025-03-17 um 11 43 14](https://github.com/user-attachments/assets/62642bcf-8946-4bcd-ba16-cdd711cac383)
1 parent db9f808 commit d3a2971

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: crates/next-api/src/app.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,13 @@ impl AppProject {
855855
graphs.push(graph);
856856
let mut visited_modules = VisitedModules::from_graph(graph);
857857

858-
for module in server_component_entries.iter() {
858+
// Skip the last server component, which is the page itself, because that one
859+
// won't have it's visited modules added, and will be visited in the next step
860+
// as part of rsc_entry
861+
for module in server_component_entries
862+
.iter()
863+
.take(server_component_entries.len().saturating_sub(1))
864+
{
859865
let graph = SingleModuleGraph::new_with_entries_visited_intern(
860866
// This should really be ChunkGroupEntry::Shared(module.await?.module),
861867
// but that breaks everything for some reason.

0 commit comments

Comments
 (0)