Skip to content

Commit

Permalink
Handle service worker error in Firefox (#8272)
Browse files Browse the repository at this point in the history
* Handle service worker error in Firefox

See https://bugzilla.mozilla.org/show_bug.cgi?id=1429714 for more details.

* Update serviceWorker.js
  • Loading branch information
rosinghal authored Jan 31, 2020
1 parent 0299c0e commit 3190e4f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions packages/cra-template-typescript/template/src/serviceWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}
10 changes: 7 additions & 3 deletions packages/cra-template/template/src/serviceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}

0 comments on commit 3190e4f

Please sign in to comment.