Ionic 3: Lazy loading of pages fails if no internet connection


I’ve set up my project according to the Ionic announcement here:

Everything works perfectly when there is even poor networking conditions. However, if I turn network connectivity completely off on device (or if I throttle the network to zero in browser using Chrome dev tools), the app crashes when I try to navigate to a page that is lazy loaded.

Is this expected behavior? Should lazy loading pages work even if the internet is disconnected on the device? Again, this occurs both on my android device, as well as in the browser.

Here is the error I see in console logs:


How exactly are you building your app?
Why is it loading stuff from localhost:8100?

Post your ionic info output as well.


I have just tried my project which has been updated to 3.5.2 - disconnected the network cable (therefore no connection) and started localhost:8100 - it worked fine.


Ok, now I understand:

You are testing with ionic serve and throttled Chrome to not have any connection any more. Correct?

This of course also disables loading of the chunks that are loaded by lazy loading. On the device these chunks are local files included in the app, but in the browser testing by ionic serve there is a webserver running on localhost:8100 that “simulates” these local files and gives them to you.

You would have to throttle everything but localhost:8100 to be able to test a “no network” situation in Chrome.


Thanks so much for the help. Here is my ionic info output:

Does it also make sense that the same issue is happening on actual android device? When I do ionic cordova run android and then turn the wifi and networking off on the device, I get the same issue.


No, that speaks against my theory. And doesn’t really make sense.

Can you create a new app with ionic start blank blank and recreate your situation in the most simple way and upload the result to Github please?


I just tried again, and it is now working as expected on my Android device. I honestly have no idea what was causing it to crash similarly before, but it must have been something different. Thank you so much for helping me to resolve this issue @Sujan12 !