File tree 1 file changed +5
-1
lines changed
packages/react-scripts/template/src
1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,9 @@ function registerValidSW(swUrl, config) {
60
60
. then ( registration => {
61
61
registration . onupdatefound = ( ) => {
62
62
const installingWorker = registration . installing ;
63
+ if ( installingWorker == null ) {
64
+ return ;
65
+ }
63
66
installingWorker . onstatechange = ( ) => {
64
67
if ( installingWorker . state === 'installed' ) {
65
68
if ( navigator . serviceWorker . controller ) {
@@ -100,9 +103,10 @@ function checkValidServiceWorker(swUrl, config) {
100
103
fetch ( swUrl )
101
104
. then ( response => {
102
105
// Ensure service worker exists, and that we really are getting a JS file.
106
+ const contentType = response . headers . get ( 'content-type' ) ;
103
107
if (
104
108
response . status === 404 ||
105
- response . headers . get ( 'content-type' ) . indexOf ( 'javascript' ) === - 1
109
+ ( contentType != null && contentType . indexOf ( 'javascript' ) === - 1 )
106
110
) {
107
111
// No service worker found. Probably a different app. Reload the page.
108
112
navigator . serviceWorker . ready . then ( registration => {
You can’t perform that action at this time.
0 commit comments