Closed
Description
EDIT: Issue appears to be with Firebase only
Service workers aren't refreshing index.html and therefore new deploys are showing old bundles.
This means production websites or really all deployed sites that use a single url/domain can not be updated.
PR #2441 - Is a hotfix (if needed) that just removes the service worker and updates docs to say they have been disabled temporarily.
@gaearon @Timer @jeffposnick @addyosmani
Steps to reproduce
create-react-app sw-test
cd sw-test
npm install
npm run build
cd build
Deploy with firebase
firebase deploy
- Visit site https://[project].firebaseapp.com. Confirm working.
- Change app.js
npm run build
cd build
deploy firebase
Check website
- Visit site again and no changes shown. DevTools shows SW is providing index.html and old bundles.
- Force refresh a few times. No difference.
- Delete service worker.
- Refresh.
- See correctly updated site.
Can someone else confirm this is affecting them?
I am hoping I am doing something wrong and this isn't affecting every production deploy.
Activity
ro-savage commentedon Jun 1, 2017
Additionally, you can not remove the service worker because if you try to unregister in a new deploy, the user will never see the updated bundle.
gaearon commentedon Jun 1, 2017
cc @jeffposnick
[-]CRITICAL: PWA / Service worker not refreshing on deployment in production[/-][+]CRITICAL: PWA / Service worker breaking production deployments[/+]bunshar commentedon Jun 1, 2017
Looks like something to do with "now". Works for me - Checked with "surge" and localhost
gaearon commentedon Jun 1, 2017
cc @rauchg
ro-savage commentedon Jun 1, 2017
Thank you @bunshar !
I tried
surge
on a new project built from scratch. And it working as expected.Deployed same app on
now
and its working as expected.No idea what happened or what I did different.
Happy to close this and assume I managed to screw something up multiple times and over-react.
I will keep an eye on my projects and see if I can narrow down what happened.
[-]CRITICAL: PWA / Service worker breaking production deployments[/-][+]PWA / Service worker breaking production deployments[/+]ro-savage commentedon Jun 1, 2017
Still running into issues on firebase.
Deploying same newly create app to
now
,surge
andfirebase
.now
andsurge
are updating.firebase
is not. (newly created project: https://cra-sw.firebaseapp.com/)Will see if its working tomorrow and will contact firebase and see what they say.
ro-savage commentedon Jun 1, 2017
Just to prove I am not crazy and this is a thing on firebase.
Deploying changes with
serve
,now
,surge
andfirebase
.Approximately 3 minutes
https://www.youtube.com/watch?v=oYy-WqkgS1Q
gaearon commentedon Jun 1, 2017
Let’s keep it open and wait for @jeffposnick to help with diagnosing this.
11 remaining items
Don't cache service worker ref facebook/create-react-app#2440
gaearon commentedon Jan 8, 2018
Closing in favor of #2398.
lusan commentedon Feb 1, 2018
Hi everyone, sorry for asking a similar question in a closed issue, thought it is related to it and the solution might be simple.
I am trying to set cache header for sw with nginx, in the configuration like it has been done in firebase, I tried
However when I load my page, sw registration fails with the message.
A bad HTTP response code (404) was received when fetching the script. registerServiceWorker.js:71 Error during service worker registration: TypeError: Failed to register a ServiceWorker: A bad HTTP response code (404) was received when fetching the script.
@gaearon @Timer @jeffposnick @addyosmani @mbleigh
Can someone please help me with this?
Don't cache service worker file
prevent service worker from caching and therefore not updating site. …
Fix blank page SW deploy. See facebook/create-react-app#2440
j-lee8 commentedon Jan 13, 2019
Is anybody still experiencing this issue? I've just created an app via create-react-app and deployed it to Firebase but when I check the Network and Application tabs in dev tools the service worker isn't there? When I do a local serve -s build it runs perfectly, but it doesn't appear to be loaded through Firebase.
Doing a Lighthouse audit it says there is no service worker on the page, yet inside the build dir the service-worker.js is there and it's also inside the asset-manifest.json.
Thanks all!