Index: sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart b/sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart |
index 73dfd5c4ec640d843de82bd5b77f186543d17ed0..ecea2cd00d9650184acf5d44b61701d08fb62bbc 100644 |
--- a/sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart |
+++ b/sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart |
@@ -251,20 +251,19 @@ class BacktrackingSolver { |
/// If there are no more versions, continues to backtrack to previous |
/// selections, and so on. If there is nothing left to backtrack to, |
/// completes to the last failure that occurred. |
- Future<List<PackageId>> _traverseSolution() => resetStack(() { |
- return new Traverser(this).traverse().catchError((error) { |
- if (error is! SolveFailure) throw error; |
- |
- return _backtrack(error).then((canTry) { |
- if (canTry) { |
- _attemptedSolutions++; |
- return _traverseSolution(); |
- } |
- |
- // All out of solutions, so fail. |
- throw error; |
- }); |
- }); |
+ Future<List<PackageId>> _traverseSolution() => resetStack(() async { |
+ // Avoid starving the event queue by waiting for a timer-level event. |
+ await new Future(() {}); |
+ |
+ try { |
+ return await new Traverser(this).traverse(); |
+ } on SolveFailure catch (error) { |
+ // All out of solutions, so fail. |
+ if (!(await _backtrack(error))) rethrow; |
+ |
+ _attemptedSolutions++; |
+ await _traverseSolution(); |
+ } |
}); |
/// Backtracks from the current failed solution and determines the next |