Repository navigation
Description
On several occasions in the past I’ve observed that if I have a long running angular.io app open in a tab, and after some time I come back to this tab and try to use it for another navigation within the app, the app responds with doc viewer progress bar indicating the document is being loaded, but it never actually loads the doc and remains in this state forever. Reloading the page resolves the issue.
When I was looking through the Google Analytics (GA) data today, I noticed that there was a spike in errors just after the holidays:
Notice how the spike starts just around Jan 7 when most people got back from holidays, and relatively quickly things come back to normal within the next few days.
If we look into the error causes, you’ll see that the main root cause is failing to download certain JS chunks, mainly the “toc-module” chunk (there are some others if you go into the report and look at the long tail of errors, but they are less common).
This makes me believe that the problem I observed in the past and this error spike after holidays are related.
Here is my interpretation of the events:
- many people were on angular.io before holidays and visited only the home page but not any api/guide doc (the toc-module case), and others visited other pages as well and their case is captured in the long tail of errors other than “toc-module”.
- these people left their app open, then came back around Jan 7 and tried to use the app for a new navigation
- in the meantime we deployed many new versions of angular.io, changing the fingeprints of chunks
- when the new navigation occured in the long-running app, the app (webpack module loader) tried to download the chunk for the missing code (e.g. toc-module)
- the server however no longer hosted that chunk because we redeployed angular.io with new versions since then and returned 404
- it’s uncommon that we fail to load code in this way, so the app just paniced and got stuck in the “loading document” state.
- user had to reload the page to recover and since reloading helped, people just shrug and moved on without reporting the problem...
There are at least three problems we need to fix:
- the module loading errors should not cause the app to freak out, we should either display the snack bar telling the user that there was an error and they should try to reload, or we should consider reloading the page automatically (but ensure we don’t end up in an infinite loop of reloads if a reload doesn’t cause the app to recover)
- look into why “toc-module” fails so frequently and consider prefetching and caching it along with the main chunk
- we should somehow deal with the client-server version skew (have service-worker cache all chunks lazily, host old chunk versions, etc)
UPDATE(2021-09-20):
See #28114 (comment) for an explanation of the problem.

Activity
fredsa commentedon Jan 13, 2019
Having the server keep old chunks for previously deployed versions could be part of the solution for angular.io, but this can't be what Angular relies on by default, as this would greatly complicate deployment of apps to hosting services that expect to be given all static content at each deployment.
Catching the error and providing a default message to end users that suggests reloading sounds pretty good. I'd add to that a hook, similar to the global handler, so devs can replace this message with their own handler code.
petebacondarwin commentedon Jan 13, 2019
That is interesting analysis @IgorMinar - I agree that we should prompt the user with a better error. Also once we land this PR (#28037) that retains the current scroll position on reload, it would be much safer to do automatic reloads.
manekinekko commentedon Jan 14, 2019
Interesting. Just an FYI, we have noticed a similar behavior with https://xlayers.app. This happens after each deployment.
Brandinga commentedon Jan 14, 2019
just my observations:
in our production enviroment, this error also happens if old chunks are not deleted.
the error is mostly sent from the current version (i added a version number to each error log)
--> but i would expect, it is reported from old versions
--> i think the problem comes also from flaky internet connections
(i did not delete old chunks since July 2018, preloadingStrategy: PreloadAllModules, no service-worker configured)
Thanks for sharing this!
gkalpak commentedon Jan 14, 2019
I am not a big fun of auto-reloading, but +100 for doing a better job at notifying the user (right now the app gets stuck on a blank screen, which is 👎).
I suspect that the reason this one fails much more often than others is that basically all docs (i.e. non-marketing pages) require the
<aio-toc>element (while other chunks/custom elements are only required some of the time). Furthermore, on small screens (e.g. mobile) the<aio-toc>chunk - when needed - is requested earlier than others via AppComponent's template directly, so it is the first request to fail and cause the error.As I've written elsewhere (see below), I still don't understand how this could be happening (although I may have some far-fetched theories), since to requested file is part of the eagerly cached
app-shellasset group (see our ngsw.json). This is the same asset group that is theoretically serving the outdatedindex.html. (So, if the outdatedindex.htmlreferencing the outdated chunks is still in the case, how come the chunks themselves aren't??? 😕)I have looked into this errors before and haven't been able to figure out why they are happening (or even how are they possible), because the SW should have the necessary files in its cache 😒
Copying my comments from Slack (not public):
juristr commentedon Jan 14, 2019
Just had the same issue opening the docs
Toxicable commentedon Jan 18, 2019
Also had this issue and made a report here: #28243 (I didn't find this issues at the time)
gkalpak commentedon Feb 8, 2019
Still not able to reproduce this reliably, but here is some more info:
This does not only happen when you have a tab open for a while. Yesterday, @benlesh run into it while having no tab open and by navigating to a docs page via a Google search results link 😞
Has anyone seen this in any other browser than Chrome?
123 remaining items
build(docs-infra): update Angular framework to version 12.2.8 (#43687)
gkalpak commentedon Oct 27, 2021
Since both #43518 (which fixed the issue for
@angular/service-worker) and #43687 (which updates angular.io to a version that includes the fix) have been merged, I am going to close this issue as "fixed" 🤞Note that people might still see the issue one more time (i.e. the first time they visit angular.io since the fix was deployed), but the error rate should be dropping (and the data from Google analytics does confirm that). We'll keep an eye on this to make sure that the error rate continues to drop.
petebacondarwin commentedon Oct 27, 2021
🎉 thank you @gkalpak for your determination and brilliance in finding a resolution to this really really annoying issue.
angular-automatic-lock-bot commentedon Dec 9, 2021
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
build(docs-infra): update Angular framework to version 12.2.8 (angula…