Tolerate the situation when a package is absent but the configured target is present: because they are retrieved in a batch, it's possible that the package node was retrieved first and still not done, while the configured target was done when retrieved.
@@ -697,11 +697,20 @@ public final class ConfiguredTargetFunction implements SkyFunction {
aliasDepsToRedo.add(dep);
continue;
} else {
+ pkgValue = (PackageValue) packageResult.get();
+ if (pkgValue == null) {
+ // In a race, the getValuesOrThrow call above may have retrieved the package
+ // before it was done but the configured target after it was done. However, the
+ // configured target being done implies that the package is now done, so we can
+ // retrieve it from the graph.
pkgValue =
Preconditions.checkNotNull(
- (PackageValue) packageResult.get(),
- "Package should have been loaded during dep resolution: %s",
- dep);
+ (PackageValue) env.getValue(packageKey),
+ "Package should have been loaded during dep resolution: %s (%s %s %s)",
+ dep,
+ depValue,
+ packageResult);
+ }
}
} else {
// We were doing AliasConfiguredTarget mop-up.
