I'm developing an angular app with multiple lazy loaded modules using angular cli. The resources (js, css and html) requires authorization which is set by a cookie. If the user is not signed in when loading the first page he will be redirected to a SSO log in page and then back to the app when successfully authorized. This flow is not something I can change.
The problem I have is that if the user loads one module, works in that module for a while and then leaves the page open but doesn't work with it more during the day. If the user then the next day starts with trying to load a route that requires another lazy module, that module will return a 401 since he no longer is authenticated. However, the user will not see that the module failed to load and feels like nothing happens.
I'm looking for a way to get notified when a lazy loaded module can't be loaded so I can redirect the user to the sign in page. Is this possible?