@@ -551,8 +551,22 @@ impl CanisterPool {
551
551
id_set. insert ( canister_id, graph. add_node ( canister_id) ) ;
552
552
}
553
553
554
+ // Verify the graph has no cycles.
555
+ if let Err ( err) = petgraph:: algo:: toposort ( & graph, None ) {
556
+ let message = match graph. node_weight ( err. node_id ( ) ) {
557
+ Some ( canister_id) => match self . get_canister_info ( canister_id) {
558
+ Some ( info) => info. get_name ( ) . to_string ( ) ,
559
+ None => format ! ( "<{}>" , canister_id. to_text( ) ) ,
560
+ } ,
561
+ None => "<Unknown>" . to_string ( ) ,
562
+ } ;
563
+ return Err ( DfxError :: new ( BuildError :: DependencyError ( format ! (
564
+ "Found circular dependency: {}" ,
565
+ message
566
+ ) ) ) )
567
+ }
568
+
554
569
// Traverse the graph of dependencies starting from `real_canisters_to_build` set.
555
- // FIXME: This hangs if circular dependencies (see below).
556
570
let mut current_canisters_to_build =
557
571
HashMap :: from_iter ( real_canisters_to_build. iter ( ) . map ( |c| ( c. canister_id ( ) , ( ) ) ) ) ;
558
572
loop {
@@ -579,22 +593,7 @@ impl CanisterPool {
579
593
current_canisters_to_build = current_canisters_to_build2;
580
594
}
581
595
582
- // Verify the graph has no cycles.
583
- if let Err ( err) = petgraph:: algo:: toposort ( & graph, None ) {
584
- let message = match graph. node_weight ( err. node_id ( ) ) {
585
- Some ( canister_id) => match self . get_canister_info ( canister_id) {
586
- Some ( info) => info. get_name ( ) . to_string ( ) ,
587
- None => format ! ( "<{}>" , canister_id. to_text( ) ) ,
588
- } ,
589
- None => "<Unknown>" . to_string ( ) ,
590
- } ;
591
- Err ( DfxError :: new ( BuildError :: DependencyError ( format ! (
592
- "Found circular dependency: {}" ,
593
- message
594
- ) ) ) )
595
- } else {
596
- Ok ( graph)
597
- }
596
+ Ok ( graph)
598
597
}
599
598
600
599
#[ context( "Failed step_prebuild_all." ) ]
0 commit comments