-
Notifications
You must be signed in to change notification settings - Fork 112
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
Error: Unexpected token '<' after publishing new version #13
Comments
It was a little difficult to get my Once I did get things working, I saw the following warning printed out in the console following the build:
If you have your HTML precached and some of its lazy-loaded dependencies aren't precached, then there can be a cache miss following a redeployment. You can learn more about this issue at https://pawll.glitch.me/ Unfortunately, But it does explain why changes to your React Component (which leads to the bloated chunk sizes) would lead to the behavior you're seeing. |
@jeffposnick thank you so much for the fast response and the feedback 😄 Sorry for the broken template. There was an old Even no chunk should be larger than 2 MB and I changed the template so it doesn't, where could I set the |
Although The actual code is at https://github.com/facebook/create-react-app/blob/aec42e2cc05fe0799a3b73830b874757e9e3f561/packages/react-scripts/config/webpack.config.js#L713-L717 |
OK. I was thinking that I'm to stupid to find where to set it. Was searching for hours 🤣 |
I don't know how common it is to ship more than 2mb of code in a given chunk, but if you think that the limit is too low, feel free to file a PR against that config file in There has to be some default (we don't want folks to accidentally precache a 1gb movie file...), but I have no objection to folks who know the |
I agree that no chung should be larger but there should be more information about this. If someone is using this template then to get a working PWA. This limit is creating a bug that is very easy to overlook. I would recommend 3 points: The warningThe warning: Is shown before the list of chunks so if you don't watch the console or scroll over the list of chunks you won't see it. If you start the build, do something else , go back and done't see any warnings but the normal message that your project is build you won't scroll above to check stuff. That is the reason I didn't notice the warning. This is how my terminal looks with the warning somewhere above: Showing the warning that one chunk will not be precached and could/will break the app (it's very hard to remove this bug on android devices) on the next update could be shown at the end or somewhere near the end of the build log. It would be good that the warning has a link to possible issues related to missing chunks in the precache. Question?It would help if a question appears in the build like The limitFor me it would make much more sense to use the warning to inform the developer that he has a to large chunk but still precache it. Even if it's larger then it should be. In the end it's better to precache a to large file than breaking the whole app with a white screen. If such a bug gets into production a normal user would get stuck with it for a while. |
The I don't think that warning and still precaching files of every size is the best option—there really should be some upper bound. It could be more than 2mb, if it's common for https://pawll.glitch.me/ has some background on the things that could wrong if there's a mismatch due to a cached HTML document that lazily-loads a JavaScript resource that is no longer available. (A good course of action is to code defensively whenever you're lazily-loading anything, as other scenarios, like just having a long-lived tab, can lead to the same failure.) In this particular scenario, the issue should be resolved when the "waiting" service worker gets a chance to activate, i.e. after all tabs are closed or after |
Unfortunately the Issue with There are no oversized chunks anymore. To reproduce you an use again the template The same App worked with the old It looks like the new service worker is overriding the cache of the old one without having the controll over all tabs. |
Your template calls Here's the code in question: https://github.com/TarikHuber/react-most-wanted/blob/master/packages/rmw-shell/cra-template-rmw/template/src/index.js#L19 The https://pawll.glitch.me/ presentation explains why calling |
omg such a stupid bug 😢 It should be a Thank you so much for the fast response and help with this! 😄 |
I have updated our custom CRA template to use the PWA features from this project. Previously it we used the setup from tha core CRA template. But since switching to this solution we have randomly the error "Unexpected token '<'" after publishing new versions of the application to the demo page (https://www.react-most-wanted.com/)
To recreate this bug just create a project with this template with:
npx create-react-app my-app --template rmw
And publish it to a Firebase project using serve localy. I could not reproduce this issue localy. IT apears in most cases when publishing to Firebase.
Here are the screenshots of the message and files in the cache:
I have searched for solutions and tried some of them but nothing could solve the issue. Tried different entries in the
package.json
file forhomepage
. Changed themanifest.json
andindex.html
to be exactly the same like in this template.Basicaly the only difference between our and this template is the stuff inside the
App
React Component. So it's strange to me that Compoenent could have any effect on the service worker.Could it be that the lazy loaded components in
App
are making this problem?Would removing clientsClaim in the SW solve this issue?
I would rather leave the files from this template the same and unchanged if it's possible.
The text was updated successfully, but these errors were encountered: