Loading chunk XYZ failed
See original GitHub issueThere is a similar issue #4152, but the main difference is that I am not using a service worker just yet and it’s a static deployment, no backend serving the content. This error did not make sense to me for a long time as I was unable to reproduce it, but yesterday it finally happened.
The scenario is quite a simple, there is a deployed app using code splitting (and React.lazy
) which is loaded into browser except that some chunks are not yet loaded because they weren’t needed before. If we deploy a new version later and suddenly user decides to go into the part of the app he wasn’t before, it is looking for an older chunk that’s not already there and 💥
I am wondering what is the proper solution to this. If there would be some way how to catch that error, I could force reload the app which ultimately is what needs to happen I suppose.
Honestly, I am a bit scared of registering service worker. The app is still heavy under development, but it’s already in a production. Sadly there is nothing like release calendar on the team and it’s not unusual to have 1-5 deployments to a production per week 🙄. Sometimes it’s more or less a critical fix that should be delivered to customer ASAP. Is there some strategy to essentially detect that new version has been deployed and force the service worker to reload?
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
Alright, thank both of you for the insight. I will probably try some skeleton app first and see if it behaves the way I need. In case it won’t, I’ll reopen this.
Oh, derp. Sorry @FredyC I totally misread this. I thought you were using the service worker – your first sentence clearly states otherwise. 😅 Sorry for roping you in, @jeffposnick!
I think this is a perfect scenario for turning on the service worker (because it solves this problem). You should be able to listen for an update event and prompt the user to force reload, manually overriding skip waiting (I think you can do this).