From b502b15f622f521d8ae8b44505fae85ff45472f1 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:55:41 +0100 Subject: [PATCH] Fix error handling --- crates/next-api/src/module_graph.rs | 81 ++++++++++++++++------------- 1 file changed, 46 insertions(+), 35 deletions(-) diff --git a/crates/next-api/src/module_graph.rs b/crates/next-api/src/module_graph.rs index e7de419c6d152..003a42de12f28 100644 --- a/crates/next-api/src/module_graph.rs +++ b/crates/next-api/src/module_graph.rs @@ -703,6 +703,46 @@ async fn get_module_graph_for_project(project: ResolvedVc) -> Vc, + graph: Vc, +) -> Result> { + let visited_modules: HashSet<_> = graph.await?.iter_nodes().map(|n| n.module).collect(); + let entries = project.get_all_entries().await?; + let additional_entries = project + .get_all_additional_entries({ + let server_actions = vec![ + async { + ServerActionsGraph::new_with_entries(graph, false) + .to_resolved() + .await + } + .instrument(tracing::info_span!("generating server actions graphs")) + .await?, + ]; + + // TODO use real object here once client_asset_context is gone + ReducedGraphs { + next_dynamic: vec![], + server_actions, + client_references: vec![], + } + .cell() + }) + .await?; + let collect = entries + .iter() + .copied() + .chain(additional_entries.iter().copied()) + .collect(); + + Ok(SingleModuleGraph::new_with_entries_visited( + Vc::cell(collect), + Vc::cell(visited_modules), + )) +} + #[turbo_tasks::value] pub struct NextDynamicGraph { is_single_page: bool, @@ -1230,45 +1270,16 @@ pub async fn get_global_module_id_strategy( project: Vc, ) -> Result> { let graph_op = get_module_graph_for_project(project); - // TODO get rid of this function once everything inside of - // `get_reduced_graphs_for_endpoint_inner` calls `take_collectibles()` when needed + // TODO get rid of this once everything inside calls `take_collectibles()` when needed let graph = graph_op.strongly_consistent().await?; let _ = graph_op.take_collectibles::>(); - let extended_graph = { - let visited_modules: HashSet<_> = graph.iter_nodes().map(|n| n.module).collect(); - let entries = project.get_all_entries().await?; - let additional_entries = project - .get_all_additional_entries({ - let server_actions = vec![ - async { - ServerActionsGraph::new_with_entries(graph_op, false) - .to_resolved() - .await - } - .instrument(tracing::info_span!("generating server actions graphs")) - .await?, - ]; - - // TODO use real object here once client_asset_context is gone - ReducedGraphs { - next_dynamic: vec![], - server_actions, - client_references: vec![], - } - .cell() - }) - .await?; - let collect = entries - .iter() - .copied() - .chain(additional_entries.iter().copied()) - .collect(); - SingleModuleGraph::new_with_entries_visited(Vc::cell(collect), Vc::cell(visited_modules)) - .await? - }; + let additional_graph_op = get_additional_module_graph_for_project(project, graph_op); + // TODO get rid of this once everything inside calls `take_collectibles()` when needed + let additional_graph = additional_graph_op.strongly_consistent().await?; + let _ = additional_graph_op.take_collectibles::>(); - let graphs = [graph, extended_graph]; + let graphs = [graph, additional_graph]; let mut idents: Vec<_> = graphs .iter()