Unverified Commit 684cf7ea authored by zydo's avatar zydo Committed by GitHub

Fix analyzer cell creation order (#100562)

## Summary

Prepare each endpoint group asynchronously, then create its chunk-group
and route-entry cells in endpoint order. This makes cell creation
deterministic and satisfies the `no-map-async-cell` lint rule without
changing the analyzer's output.

## Verification

- `pnpm lint-ast-grep`
- `pnpm build-all`
- `cargo fmt --all -- --check`
- `TMPDIR=/private/tmp pnpm test-start-turbo
test/e2e/next-analyze/next-analyze.test.ts` (6 tests passed)

<!-- NEXT_JS_LLM -->
parent 3da24ee7
...@@ -206,7 +206,7 @@ async fn get_analyze_data_operation( ...@@ -206,7 +206,7 @@ async fn get_analyze_data_operation(
} }
} }
let analyze_data_and_summaries = endpoint_groups let prepared_endpoint_groups = endpoint_groups
.iter() .iter()
.map(async |(key, endpoint_group)| { .map(async |(key, endpoint_group)| {
let output_assets = if has_combined let output_assets = if has_combined
...@@ -263,39 +263,49 @@ async fn get_analyze_data_operation( ...@@ -263,39 +263,49 @@ async fn get_analyze_data_operation(
{ {
groups.extend(shared_chunk_groups.iter().cloned()); groups.extend(shared_chunk_groups.iter().cloned());
} }
Ok((key, output_assets, traced_files, groups, entries))
})
.try_join()
.await?;
let analyze_data_and_summaries = prepared_endpoint_groups
.into_iter()
.map(|(key, output_assets, traced_files, groups, entries)| {
let chunk_groups: Vc<AnalyzeChunkGroups> = Vc::cell(groups); let chunk_groups: Vc<AnalyzeChunkGroups> = Vc::cell(groups);
let route_entries: Vc<AnalyzeRouteEntries> = Vc::cell(entries); let route_entries: Vc<AnalyzeRouteEntries> = Vc::cell(entries);
let analyze_data = AnalyzeDataOutputAsset::new( async move {
analyze_output_root let analyze_data = AnalyzeDataOutputAsset::new(
.join(&key.to_string())? analyze_output_root
.join("analyze.data")?, .join(&key.to_string())?
output_assets, .join("analyze.data")?,
traced_files, output_assets,
route_entries, traced_files,
chunk_groups, route_entries,
*whole_app_module_graphs.await?.full, chunk_groups,
) *whole_app_module_graphs.await?.full,
.to_resolved() )
.await?; .to_resolved()
.await?;
let summary = if let EndpointGroupKey::Route(route) = key { let summary = if let EndpointGroupKey::Route(route) = key {
Some(RouteSummary { Some(RouteSummary {
route: route.to_string(), route: route.to_string(),
bundles: analyze_output_assets( bundles: analyze_output_assets(
output_assets, output_assets,
traced_files, traced_files,
route_entries, route_entries,
chunk_groups, chunk_groups,
*whole_app_module_graphs.await?.full, *whole_app_module_graphs.await?.full,
) )
.await? .await?
.summary, .summary,
}) })
} else { } else {
None None
}; };
Ok((ResolvedVc::upcast(analyze_data), summary)) Ok((ResolvedVc::upcast(analyze_data), summary))
}
}) })
.try_join() .try_join()
.await?; .await?;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment