From 7cadd05c430089fd202919d1aca6edaf42b6fbcb Mon Sep 17 00:00:00 2001
From: Rohit Singhal <rohitsinghal.rs@gmail.com>
Date: Fri, 3 Jan 2020 06:34:34 +0530
Subject: [PATCH 1/2] Handle service worker error in Firefox

See https://bugzilla.mozilla.org/show_bug.cgi?id=1429714 for more details.
---
 .../template/src/serviceWorker.ts                      | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/packages/cra-template-typescript/template/src/serviceWorker.ts b/packages/cra-template-typescript/template/src/serviceWorker.ts
index d5f0275a77d..b09523f155e 100644
--- a/packages/cra-template-typescript/template/src/serviceWorker.ts
+++ b/packages/cra-template-typescript/template/src/serviceWorker.ts
@@ -138,8 +138,12 @@ function checkValidServiceWorker(swUrl: string, config?: Config) {
 
 export function unregister() {
   if ('serviceWorker' in navigator) {
-    navigator.serviceWorker.ready.then(registration => {
-      registration.unregister();
-    });
+    navigator.serviceWorker.ready
+      .then(registration => {
+        registration.unregister();
+      })
+      .catch(error => {
+        console.error(error.message);
+      });
   }
 }

From 84c7ac23b72d2e33dac606ad514262b815201b2c Mon Sep 17 00:00:00 2001
From: Rohit Singhal <rohitsinghal.rs@gmail.com>
Date: Fri, 31 Jan 2020 20:05:20 +0530
Subject: [PATCH 2/2] Update serviceWorker.js

---
 packages/cra-template/template/src/serviceWorker.js | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/packages/cra-template/template/src/serviceWorker.js b/packages/cra-template/template/src/serviceWorker.js
index 8703ddb7ecb..c4838eb55f0 100644
--- a/packages/cra-template/template/src/serviceWorker.js
+++ b/packages/cra-template/template/src/serviceWorker.js
@@ -130,8 +130,12 @@ function checkValidServiceWorker(swUrl, config) {
 
 export function unregister() {
   if ('serviceWorker' in navigator) {
-    navigator.serviceWorker.ready.then(registration => {
-      registration.unregister();
-    });
+    navigator.serviceWorker.ready
+      .then(registration => {
+        registration.unregister();
+      })
+      .catch(error => {
+        console.error(error.message);
+      });
   }
 }