Service Worker breaks the app in Firefox
Created by: ketysek
Is this a bug report?
Yes
Did you try recovering your dependencies?
Yes, I've tried it on fresh installed app
Which terms did you search for in User Guide?
service worker, progressive web app
Environment
macOS Mojave (10.14.3), Firefox 66.0 (65.0 worked same), current 2.1.8 react-scripts
Steps to Reproduce
- create an app (npx create-react-app my-app)
- update
index.js
- instead ofserviceWorker.unregister()
callserviceWorker.register()
yarn run build
- run server with production app code:
serve -s -l 3000 build
- open
localhost:3000
in Firefox - verify that service worker is activated
- stop serve server
- change something (for example text) in
App.js
-
yarn run build
again - run server again
- refresh the firefox tab with opened app
Expected Behavior
New service worker should be installed and in waiting state
Actual Behavior
It throws error in console and service worker isn't updated:
Failed to register/update a ServiceWorker for scope ‘http://localhost:3000/’: Bad Content-Type of ‘text/html’ received for script ‘http://localhost:3000/precache-manifest.5df49f687d80bec80e0acf86555252db.js’. Must be a JavaScript MIME type.
When I unregister service worker from Firefox and refresh the tab, it's again working for first time - then you refresh the tab (immediately) for the second time and it again throws the same error in console and also crashes (doesn't display the app) with another error in console:
SyntaxError: expected expression, got '<'[Learn More] main.5f3bc8a8.chunk.js:1