diff --git a/crates/next-api/src/app.rs b/crates/next-api/src/app.rs index b61ef3375e..fbfcf9b367 100644 --- a/crates/next-api/src/app.rs +++ b/crates/next-api/src/app.rs @@ -1995,11 +1995,21 @@ impl AppEndpoint { ) .await?; + // The server actions loader is a separate graph entry that is not reachable from + // rsc_entry, but it is chunked into the endpoint output, so its modules (e.g. externals + // imported by actions) must be traced as well. + let mut entry_modules = vec![rsc_entry]; + entry_modules.extend( + self.additional_entries(*module_graphs.base) + .await? + .all_modules(), + ); + Ok(trace_endpoint( this.app_project.project(), Some(app_function_name(&app_entry.original_name).into()), *module_graphs.full, - *rsc_entry, + Vc::cell(entry_modules), )) } } diff --git a/crates/next-api/src/instrumentation.rs b/crates/next-api/src/instrumentation.rs index c08773bf03..2515c48e5c 100644 --- a/crates/next-api/src/instrumentation.rs +++ b/crates/next-api/src/instrumentation.rs @@ -200,12 +200,12 @@ impl InstrumentationEndpoint { #[turbo_tasks::function] async fn trace_result(self: Vc) -> Result> { let this = self.await?; - let userland_module = self.entry_module(); + let userland_module = self.entry_module().to_resolved().await?; Ok(trace_endpoint( *this.project, None, - this.project.module_graph(userland_module), - userland_module, + this.project.module_graph(*userland_module), + Vc::cell(vec![userland_module]), )) } } diff --git a/crates/next-api/src/middleware.rs b/crates/next-api/src/middleware.rs index 2bbba57500..a2e0f9814a 100644 --- a/crates/next-api/src/middleware.rs +++ b/crates/next-api/src/middleware.rs @@ -342,12 +342,12 @@ impl MiddlewareEndpoint { #[turbo_tasks::function] async fn trace_result(self: Vc) -> Result> { let this = self.await?; - let userland_module = self.entry_module(); + let userland_module = self.entry_module().to_resolved().await?; Ok(trace_endpoint( *this.project, None, - this.project.module_graph(userland_module), - userland_module, + this.project.module_graph(*userland_module), + Vc::cell(vec![userland_module]), )) } } diff --git a/crates/next-api/src/nft.rs b/crates/next-api/src/nft.rs index f09e23c000..6d08c15467 100644 --- a/crates/next-api/src/nft.rs +++ b/crates/next-api/src/nft.rs @@ -61,7 +61,7 @@ pub async fn trace_endpoint( project: ResolvedVc, page_name: Option, module_graph: ResolvedVc, - entry_module: ResolvedVc>, + entry_modules: Vc, ) -> Result> { let span = tracing::info_span!("trace endpoint", path = debug(&page_name)); async { @@ -78,7 +78,7 @@ pub async fn trace_endpoint( // Collect referenced assets and externals from module graph let all_modules = traced_modules_for_entries( *module_graph, - Vc::cell(vec![entry_module]), + entry_modules, traced_entries, tracing_exclude_glob(page_name.clone(), project_path.clone(), next_config) .await? diff --git a/crates/next-api/src/pages.rs b/crates/next-api/src/pages.rs index b89d365860..594eb93142 100644 --- a/crates/next-api/src/pages.rs +++ b/crates/next-api/src/pages.rs @@ -1591,7 +1591,7 @@ impl PageEndpoint { this.pages_project.project(), Some(pages_function_name(&this.original_name).into()), ssr_module_graph, - *ssr_module, + Vc::cell(vec![ssr_module]), )) } }