-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cached SW index.html gets a 404 error on old bundle #3882
Comments
cc @jeffposnick |
Here is an example of a generated
As you can see there is no This is what the build process logged:
|
I tried a few more things and it seems like when I comment out some code it does gets included in the SW precache list. But it's not a particular piece of code, so it looks like it's related to the file size. The current size is far below the maximum default size in SWPrecache (which is 2MB) and as far as I can tell CRA doesn't change that limit. |
Here are some "odd" things that your screenshots/code snippets illustrate which I'd like to get to the bottom of:
You may be on the right track regarding size limits, as |
@jeffposnick I'm not sure how I can see the unminified file size with |
It's going to get trickier to justify showing the logged output from the |
Maybe it could be a general warning like “hey be warned your bundle (or chunk) is big (and will not be cached for offline use if you use a service worker), consider splitting it in multiple chunks to improve load time” or something |
FWIW, I found #2612 which effectively tracks the same request (and is closed). |
Had same issue. As it referenced I've outline some thought here. #3574 |
@rogovdm i'm using firebase hosting as well and facing the same problem, have you fixed it? |
yep same here. Have tried adding header caching rules to the header section with no success. Currently trying to unregister the serviceWorker but this seems like a horrid way to get around this bug. I swear this used to work just fine. So not sure where the issue began. But judging on the history of react devs and how often issue threads just close down due to inactivity, I doubt this will be addressed any time soon. |
I have the same problem. |
Any update on this or the only real solution is to opt-out of caching? |
@sh00ter the solution is code splitting. See one of my comments above. |
@rovansteen I am using Loadable to split the code but I guess that one of the chunks is still large enough not to be picked up by the service worker. |
@sh00ter yeah unfortunately there is no warning or anything like that to see if one of the bundles is too big so we do this by manually checking it. |
But you could implement something like this to automate that process: #2612 (comment) |
solution worked for me |
@Timer I hit this very same issue today after deployment using latest CRA Manually unregistering the worker and refreshing makes the site load, but any subsequent refreshes just crashes it again for me. Used to work just fine with previous versions, mind you ( I believe this issue should be re-opened. EDIT 294.54 KB build/static/js/1.7199b771.chunk.js
49.06 KB build/static/js/main.2c86934a.chunk.js
21.38 KB build/static/css/main.ff66eee3.chunk.css
1.6 KB build/static/css/1.fdfa198a.chunk.css As you can see from the names of the chunks resulting from the build and the ones being fetched from the worker (screenshot), I'm at a loss here, at the moment. |
Please file a new issue if you believe you're experiencing a bug. |
Is this a bug report?
Yes
Did you try recovering your dependencies?
Yes, happened on multiple deployments.
Which terms did you search for in User Guide?
Read the parts about service worker and also searched for similar issues, found this one: #3613 but that was about chunking, which I do not use.
Environment
node -v
: 9.4.0npm -v
: 5.6.0yarn --version
(if you use Yarn): 1.3.2npm ls react-scripts
(if you haven’t ejected): n/aThen, specify:
Expected Behavior
When I deploy a new version of my application I expect it to load the old HTML and load the old JS bundle from it's cache. If that's no longer available (for whatever reason) it should fetch the new HTML and with that also the new JS bundle.
Actual Behavior
The service worker serves the old index.html, but it tries to get the JS bundle from the server. Because a new version has been deployed that bundle is no longer there, so it receives a 404 error, resulting in a white (broken) page. Refreshing the page fixes the issue.
The contents of my index.js
Here screenshots of the network tab during the 'broken state'
The text was updated successfully, but these errors were encountered: