RouteConfigLoadStart event not firing if the navigation of a lazy loaded route was previously canceled
See original GitHub issueWhich @angular/* package(s) are the source of the bug?
router
Is this a regression?
No
Description
If the navigation of a lazy loaded route was previously canceled, the RouteConfigLoadStart
event is never fired again, although the RouteConfigLoadEnd
fires.
It seams that the loader that contains the observable is returned immediately without triggering the RouteConfigLoadStart
. This invalidates the possibility to track the loading progress of a route when the navigation is canceled and resumed sometime in the future (see code below).
I am not sure how I can provide a reproduction for this since the loading of the route is network dependent, but I think that by looking at the code below, is easy to understand the problem.
load(parentInjector: Injector, route: Route): Observable<LoadedRouterConfig> {
if (route._loader$) {
return route._loader$;
}
if (this.onLoadStartListener) {
this.onLoadStartListener(route);
}
...
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in (run ng version
)
Angular CLI: 13.1.2
Node: 12.22.2
Package Manager: npm 6.14.13
OS: win32 x64
Angular: 13.1.1
... animations, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1301.2
@angular-devkit/build-angular 13.1.2
@angular-devkit/core 13.1.2
@angular-devkit/schematics 13.1.2
@angular/cli 13.1.2
@schematics/angular 13.1.2
ng-packagr 13.0.8
rxjs 7.4.0
typescript 4.4.4
Anything else?
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (9 by maintainers)
Top Results From Across the Web
Lazy Loaded Routing Problem after Upgrade to Angular 11
Logging out at the Router events in ng11, the feature module is loaded, and RouteConfigLoadStart and RouteConfigLoadEnd are both triggered with ...
Read more >Angular Router Events
It is triggered when the navigation is canceled either by the user ( NavigationCancel ) ... RouteConfigLoadStart, the Router lazy loads a route...
Read more >RouteConfigLoadStart
An event triggered before lazy loading a route configuration. class RouteConfigLoadStart { constructor(route: Route) type: EventType.
Read more >Angular Routing Events and debugging
When we navigate through router by routerLink, navigateByUrl() or navigate() , each time Angular Router emit events for each phase of ...
Read more >In-app navigation: routing to views - Angular
However, if you are creating an app manually or working with an existing, ... routes to lazy load modules, which means that Angular...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This really does need a reproduction. The intent was to clear the loader if it was unsuccessful but this would not happen if it completes without an error https://github.com/angular/angular/blob/8ebc946c0e7bf80d26ec8268acb4ff0af9e5c34a/packages/router/src/router_config_loader.ts#L60-L63 I’m not sure exactly how that would happen, but this appears as though it could be the issue.
That said, the ordering of the event is correct and the fact that it’s not called if
_loader$
already exists is also correct. The preloader and a navigation can both request a lazy loaded route to be loaded at the same time. The code prevents double loading and double listener notification.onLoadStartListener
should not be called twice in this case.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.