Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
dfcc363b
Commit
dfcc363b
authored
Nov 21, 2025
by
Niklas Mischkulnig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix async cycle
parent
36f50c5a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
20 deletions
+40
-20
async_module_info.rs
...ates/turbopack-core/src/module_graph/async_module_info.rs
+35
-13
export_usage.rs
...ck/crates/turbopack-core/src/module_graph/export_usage.rs
+1
-1
mod.rs
turbopack/crates/turbopack-core/src/module_graph/mod.rs
+3
-3
module_batches.rs
.../crates/turbopack-core/src/module_graph/module_batches.rs
+1
-3
No files found.
turbopack/crates/turbopack-core/src/module_graph/async_module_info.rs
View file @
dfcc363b
use
anyhow
::
Result
;
use
rustc_hash
::
FxHashSet
;
use
rustc_hash
::{
FxHashMap
,
FxHashSet
};
use
smallvec
::
SmallVec
;
use
turbo_tasks
::{
ResolvedVc
,
TryJoinIterExt
,
Vc
};
use
crate
::{
...
...
@@ -72,8 +73,30 @@ async fn compute_async_module_info_single(
// strongly-connected components, and then marking all the whole SCC as async if one of the
// modules in the SCC is async.
let
mut
async_modules
=
self_async_modules
;
let
graph_ref
=
graph
.read
();
let
mut
async_modules
=
self_async_modules
;
let
mut
cycles
=
vec!
[];
let
mut
cycle_entries
:
FxHashMap
<
ResolvedVc
<
_
>
,
SmallVec
<
[
usize
;
1
]
>>
=
Default
::
default
();
graph_ref
.traverse_cycles
(
|
ref_data
|
ref_data
.chunking_type
.is_inherit_async
(),
|
cycle
|
{
let
cycle_idx
=
cycles
.len
();
cycles
.push
(
cycle
.to_vec
());
for
module
in
cycle
{
// For later when we propagate async-ness to parents
cycle_entries
.entry
(
*
module
)
.or_default
()
.push
(
cycle_idx
);
}
// For the self_async_modules
if
cycle
.iter
()
.any
(|
node
|
async_modules
.contains
(
node
))
{
async_modules
.extend
(
cycle
.iter
()
.copied
());
}
Ok
(())
},
)
?
;
graph_ref
.traverse_edges_from_entries_dfs
(
graph
.entry_modules
(),
&
mut
(),
...
...
@@ -85,17 +108,16 @@ async fn compute_async_module_info_single(
};
if
ref_data
.chunking_type
.is_inherit_async
()
&&
async_modules
.contains
(
&
module
)
{
async_modules
.insert
(
parent_module
);
}
Ok
(())
},
)
?
;
graph_ref
.traverse_cycles
(
|
ref_data
|
ref_data
.chunking_type
.is_inherit_async
(),
|
cycle
|
{
if
cycle
.iter
()
.any
(|
node
|
async_modules
.contains
(
node
))
{
async_modules
.extend
(
cycle
.iter
()
.map
(|
n
|
**
n
));
let
newly_async
=
async_modules
.insert
(
parent_module
);
if
newly_async
{
for
cycle
in
cycle_entries
.get
(
&
parent_module
)
.iter
()
.flat_map
(|
v
|
v
.iter
())
{
async_modules
.extend
(
cycles
[
*
cycle
]
.iter
()
.copied
());
}
}
}
Ok
(())
},
...
...
turbopack/crates/turbopack-core/src/module_graph/export_usage.rs
View file @
dfcc363b
...
...
@@ -40,7 +40,7 @@ pub async fn compute_export_usage_info(
// rare. For vercel-site on 8/22/2025 there were 106 cycles covering 800 modules
// (or 1.2% of all modules). So with this analysis we could potentially drop 80% of
// the cycle breaker modules.
circuit_breakers
.extend
(
cycle
.iter
()
.
map
(|
n
|
**
n
));
circuit_breakers
.extend
(
cycle
.iter
()
.
copied
(
));
Ok
(())
},
)
?
;
...
...
turbopack/crates/turbopack-core/src/module_graph/mod.rs
View file @
dfcc363b
...
...
@@ -414,7 +414,7 @@ impl SingleModuleGraph {
fn
traverse_cycles
<
'l
>
(
&
'l
self
,
edge_filter
:
impl
Fn
(
&
'l
RefData
)
->
bool
,
mut
visit_cycle
:
impl
FnMut
(
&
[
&
'l
ResolvedVc
<
Box
<
dyn
Module
>>
])
->
Result
<
()
>
,
mut
visit_cycle
:
impl
FnMut
(
&
[
ResolvedVc
<
Box
<
dyn
Module
>>
])
->
Result
<
()
>
,
)
->
Result
<
()
>
{
// see https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm
// but iteratively instead of recursively
...
...
@@ -491,7 +491,7 @@ impl SingleModuleGraph {
if
let
SingleModuleGraphNode
::
Module
(
module
)
=
self
.graph
.node_weight
(
poppped
)
.unwrap
()
{
scc
.push
(
module
);
scc
.push
(
*
module
);
}
if
poppped
==
node
{
break
;
...
...
@@ -1182,7 +1182,7 @@ impl ModuleGraphRef {
pub
fn
traverse_cycles
(
&
self
,
edge_filter
:
impl
Fn
(
&
RefData
)
->
bool
,
mut
visit_cycle
:
impl
FnMut
(
&
[
&
ResolvedVc
<
Box
<
dyn
Module
>>
])
->
Result
<
()
>
,
mut
visit_cycle
:
impl
FnMut
(
&
[
ResolvedVc
<
Box
<
dyn
Module
>>
])
->
Result
<
()
>
,
)
->
Result
<
()
>
{
for
graph
in
&
self
.graphs
{
graph
.traverse_cycles
(
&
edge_filter
,
&
mut
visit_cycle
)
?
;
...
...
turbopack/crates/turbopack-core/src/module_graph/module_batches.rs
View file @
dfcc363b
...
...
@@ -392,9 +392,7 @@ pub async fn compute_module_batches(
.iter
()
.any
(|
node
|
pre_batches
.boundary_modules
.contains
(
node
))
{
pre_batches
.boundary_modules
.extend
(
cycle
.iter
()
.map
(|
node
|
**
node
));
pre_batches
.boundary_modules
.extend
(
cycle
.iter
()
.copied
());
}
Ok
(())
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment