Uncaught (in promise): Error: Loading chunk 20 failed

I used the ‘The Ionic Super Starter’

Don’t remember, but I followed every CHANGELOG carefully

Are you using lazy loading @sebaferreras and @cmartin ?

Yes, I’m using lazy loading but only as it comes by default (I’m only using the @IonicPage() decorator without preloading anything) @reedrichards

I’m also using lazy loading. With @ionicPage decorator and using the string name of the class when pushing to the navCtrl.

We are all using lazy loading, if I understand correctly the error comes from webpack not being able to load dynamically code and the stackoverflow issue I listed above goes in the same direction … that might be the way to follow to understand the problem

@sebaferreras and @cmartin do you set preloadModules to true in your app.module.ts

IonicModule.forRoot(MyApp, {
  ...,
  preloadModules: true
}),

if no, would you like to give a try? is it better or worse?

Thanks. I’ll give it a try. But this is something that only occurs 1 of 10 times… so I’ll report back next time I get the error. I’m on a new mac now. So I have to get everything up and that could take a day or two…

No worries, weird bug are often not that easily and really fast solved :wink:

Looking forward to your feedback

Have you tried this? Did it work?

Yes I do use preloadModules: true, it works fine but still like I said see the error rarely therefore I ask my self if it helps or not

Thanks @reedrichards for your suggestion.

I didn’t try it yet but I guess that may decrease the amount of times that the error happens since the modules are going to be preloaded instead of being loaded when the user tries to enter to each page.

But still, the issue seems to be related to the way webpack resolves and loads some lazy loaded pages/modules for some reason…

@sebaferreras agree with you, keep me posted

I get a clean Sentry stack right now, I will follow the situation to see if this happens again

Dammit… I got the errormessage again… now it has problem loading chunk 3.

ERROR Error: Uncaught (in promise): Error: Loading chunk 3 failed.
onScriptComplete@http://localhost:8080/var/containers/Bundle/Application/B920444F-7CA0-40F5-A818-FC4F6DB3DBBD/My%20App.app/www/build/vendor.js:1:701

So preloadModules did not help.

:frowning:

I more and more think that the problem is linked to Lazy Loading and cache problem respectively maybe when user update their apps (?), when I google stuffs like “Uncaught (in promise): Error: Loading chunk” there are actually a couple of posts about it

@cmartin and @sebaferreras do you observe the error only on iOS, only on Android or both?

do you use Ionic pro?

do you observe the error more often when you push new version in stores or when you push new app bundle with pro?

we know we all use lazy loading, let’s try to see if there is a specific platform or flow which lead to the error…if that could help and let us discover something…

The problem is only on IOS. And it is only happening during app startup(either by clicking the App Ikon or by a push notification).
I do not use ionic hot deploy so I only push new version in stores.

I have a bunch of sentry logs, for this error, which I will go through tomorrow. Sentry do also logout the console, so I might find something interesting there (I hope).

thx for your answer @cmartin, let’s see what @sebaferreras will answer but if he confirms iOS we could summarize like following

  • We use lazy loading
  • It only happens on iOS
  • It only happens at boot time

furthermore

  • I suspect that the problem happens at boot time but maybe when app have been updated too (like there is some cache of the app staying on the phone and because the chunks hash or whatever of the new apps aren’t the same names as before the loading doesn’t find them or try to find them with the wrong name…wild guess)

but most important

  • maybe it has something to do with cordova-plugin-ionic-webview. if so I suggest we open an issue, it just gonna be super difficult to explain and even more difficult to provide a sample repo, chance of fix is small, but who knows

+1 for iOS only, @whitt already wrote here above that he only face the problem on iPhone devices

I did open an issue, really not sure and stuffs, but even if they will close it, it may give some more info, follow:

1 Like

@reedrichards I can confirm these three things:

  • We use lazy loading
  • It only happens on iOS
  • It only happens at boot time

I’m using Raygun for error reporting and seems like the error happens only once per user (not sure how Raygun identifies devices though but this could confirm that it only happens at boot time after updating the app and not every time the user opens the app).

I can share the Raygun logs if you think it could help, but there’s nothing new besides what @whitt and you guys already included in this thread.

1 Like