Skip to content

Commit faf7b1b

Browse files
committed
Turbopack: make GraphTraversal deterministically calling all nodes before erroring
1 parent 8c7dd5d commit faf7b1b

2 files changed

Lines changed: 3 additions & 18 deletions

File tree

turbopack/crates/turbo-tasks/src/graph/control_flow.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,4 @@ pub enum VisitControlFlow {
88
/// The edge is excluded, and the traversal should not continue on the outgoing edges of the
99
/// given node.
1010
Exclude,
11-
/// The traversal should abort and return immediately.
12-
Abort,
1311
}

turbopack/crates/turbo-tasks/src/graph/graph_traversal.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ where
4242
Impl: Send,
4343
{
4444
let mut futures = FuturesUnordered::new();
45-
let mut is_abort = false;
4645

4746
// Populate `futures` with all the roots, `root_nodes` isn't required to be `Send`, so this
4847
// has to happen outside of the future. We could require `root_nodes` to be `Send` in the
@@ -62,18 +61,11 @@ where
6261
VisitControlFlow::Exclude => {
6362
// do nothing
6463
}
65-
VisitControlFlow::Abort => {
66-
// this must be returned inside the `async` block below so that it's part of the
67-
// returned future
68-
is_abort = true;
69-
}
7064
}
7165
}
7266

7367
async move {
74-
if is_abort {
75-
return GraphTraversalResult::Aborted;
76-
}
68+
let mut result = Ok(());
7769
loop {
7870
match futures.next().await {
7971
Some((parent_node, span, Ok(edges))) => {
@@ -94,17 +86,14 @@ where
9486
VisitControlFlow::Exclude => {
9587
// do nothing
9688
}
97-
VisitControlFlow::Abort => {
98-
return GraphTraversalResult::Aborted;
99-
}
10089
}
10190
}
10291
}
10392
Some((_, _, Err(err))) => {
104-
return GraphTraversalResult::Completed(Err(err));
93+
result = Err(err);
10594
}
10695
None => {
107-
return GraphTraversalResult::Completed(Ok(self));
96+
return GraphTraversalResult::Completed(result.map(|()| self));
10897
}
10998
}
11099
}
@@ -114,14 +103,12 @@ where
114103

115104
pub enum GraphTraversalResult<Completed> {
116105
Completed(Completed),
117-
Aborted,
118106
}
119107

120108
impl<Completed> GraphTraversalResult<Completed> {
121109
pub fn completed(self) -> Completed {
122110
match self {
123111
GraphTraversalResult::Completed(completed) => completed,
124-
GraphTraversalResult::Aborted => panic!("Graph traversal was aborted"),
125112
}
126113
}
127114
}

0 commit comments

Comments
 (0)