angular: 10.1.0 Router empty path regression

🐞 bug report

Summary

Upgrading to Angular 10.1.0 does not stop routing on the first matching route entry.

Is this a regression?

Yes, this used to work in all previous versions of Angular (from v2 onwards).

Description

Previous versions of Angular allowed routes to be defined in a prioritized order. As per the screenshot below, we direct the route to specific module if a path is provided, however if no path is provided, we route to the main application module.

image

It appears that V10.1.0 now triggers the last path (the one highlighted in the screenshot above) even if the other paths load first. In our case, if we try to login via the auth path, it first shows the login page for a brief few milliseconds and then it tries to navigate to the main module via the path: '' entry but this fails the auth check and redirects back to the auth module and this cycle then repeats forever.

πŸ”¬ Minimal Reproduction

Removing the highlighted line in the above screenshot stops the repeated loading from occurring. But this isn’t a fix as it stops our app from working as well.

🌍 Your Environment

Angular Version:


Angular CLI: 10.1.0
Node: 12.10.0
OS: linux x64

Angular: 10.1.0
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.1000.7
@angular-devkit/build-angular     0.1001.0
@angular-devkit/build-optimizer   0.1001.0
@angular-devkit/build-webpack     0.1001.0
@angular-devkit/core              10.0.7
@angular-devkit/schematics        10.1.0
@angular/cdk                      10.1.3
@ngtools/webpack                  10.1.0
@schematics/angular               10.1.0
@schematics/update                0.1001.0
rxjs                              6.6.2
typescript                        3.9.7
webpack                           4.44.1

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 22 (5 by maintainers)

Commits related to this issue

Most upvoted comments

Note that as a temporary workaround, you can use return this.router.createUrlTree(['auth']); instead of

this.router.navigate(['auth']);
return false;

because the PR was meant to respect the ordering with prioritization, but only works with returning UrlTrees and fails to do so if a guard calls router.navigate to β€œredirect” which cancels the current navigation immediately and proceeds with the new one.

@AlexanderOpran I wonder if it is worth you raising this as your own issue and linking back to this one or including my stackblizt replicating the issue? All the newer bugs seem to be getting assigned to people and have confirmed tags etc. This one seems to have been lost.