Browse Source

fix(ui) Catch network errors when fetching status page (#31485)

When requests to statuspage.io fail we don't need to be alerted as there
isn't anything we can do.

Refs JAVASCRIPT-231K
Mark Story 3 years ago
parent
commit
94e114f30a
1 changed files with 10 additions and 3 deletions
  1. 10 3
      static/app/actionCreators/serviceIncidents.tsx

+ 10 - 3
static/app/actionCreators/serviceIncidents.tsx

@@ -46,14 +46,21 @@ function getIncidentsFromIncidentResponse(statuspageIncidents: StatuspageInciden
 
 export async function loadIncidents(): Promise<SentryServiceStatus | null> {
   const cfg = ConfigStore.get('statuspage');
+  let response: Response | undefined = undefined;
   if (!cfg || !cfg.id) {
     return null;
   }
-  const response = await fetch(
-    `https://${cfg.id}.${cfg.api_host}/api/v2/incidents/unresolved.json`
-  );
+  try {
+    response = await fetch(
+      `https://${cfg.id}.${cfg.api_host}/api/v2/incidents/unresolved.json`
+    );
+  } catch (err) {
+    // No point in capturing this as we can't make statuspage come back.
+    return null;
+  }
 
   if (!response.ok) {
+    // Sometimes statuspage responds with a 500
     return null;
   }