diff --git a/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceModule.java b/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceModule.java index 349a4e4f63fc81..8bcfb37b317d4a 100644 --- a/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceModule.java +++ b/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceModule.java @@ -190,6 +190,18 @@ private void waitForPreviousInvocation() { return; } + ConnectivityStatus status = connectivityProvider.getStatus(CONNECTIVITY_CACHE_KEY); + if (status.status != ConnectivityStatus.Status.OK) { + reporter.handle( + Event.info( + String.format( + "The Build Event Protocol encountered a connectivity problem: %s. Cancelling" + + " previous background uploads", + status))); + cancelPendingUploads(); + return; + } + Stopwatch stopwatch = Stopwatch.createStarted(); try { // TODO(b/234994611): It would be better to report before we wait, but the current @@ -616,8 +628,7 @@ private BuildEventServiceTransport createBesTransport( clearBesClient(); String message = String.format( - "Build Event Service uploads disabled due to a connectivity problem: %s", - status.toString()); + "Build Event Service uploads disabled due to a connectivity problem: %s", status); reporter.handle(Event.warn(message)); googleLogger.atWarning().log(message); return null;