question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

10.1.0 Router empty path regression

See original GitHub issue

🐞 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

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
atscottcommented, Sep 9, 2020

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.

1reaction
akturatechcommented, Sep 9, 2020

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 9.1.5 Router empty path is not working
I found that some people get the same issue with Angular 10.1.0, but I tried the solution that they used to fix it...
Read more >
angular routing not working on the hosted linux
I have an app with Angular. It is a simple list of items, after clicking on an item opened item details page. Two...
Read more >
Step 9. Leaving some part of the network unconfigured
The routing tables of all hosts contain subnet routes to these three LANs. Since these hosts don't have addresses at the start of...
Read more >
Troubleshoot Open Shortest Path First Route Database ...
This kind of network type mismatch makes the advertising router unreachable. R4-4K(4)#show ip ospf database router 172.16.32.2 Adv Router is not ...
Read more >
Route
It is important to do this when redirecting empty-path routes. Otherwise, because an empty path is a prefix of any URL, the router...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found