New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
10.1.0 Router empty path regression #38691
Comments
i think you will have to add pathMatch:"full" in you blank path:"" |
Good morning @indraraj26 . Thank you for your suggestion. I tested this and unfortunately it doesn't work. The reason is that the last route redirects to our main module which has many routes of its own. With a full match, the routes within the main module no longer work. Hopefully this explains our routing system (which was implemented when the first version of angular was released with lazy loaded modules and has worked until now):
Some examples paths are:
|
Hi @akturatech , Do you have router-outlet in MainComponent.html it is needed so that children can render, as you are not using component-less routing. Also is it possible for you to provide reproduction via stackblitz ? |
Hi @indraraj26,
Yes i do.
Yes sure... Example project is here in v10.0.9. It works: https://stackblitz.com/edit/angular-ivy-crjaz8?file=src%2Fapp%2Fguard%2Fa.guard.ts The reason is that the guard on the empty path in the app module is running when it shouldn't be. It should run only when the path: '' is activated, but it runs even if we go to '/auth' path. This is only happening in 10.1.0 and not in older versions. Note that the empty path is not activating as it is not printing "main works!". I believe routing is working as it should. It appears that canLoad guard though is incorrectly firing. In my main app, we use the guard on the empty path to check that the user is authorised and redirect back to the 'auth' path if they are not. In v10.1, as the guard is now firing even when we go to 'auth' path, it is failing auth check and returning false and redirecting back to auth path, which causes the guard to check again and repeat forever. |
One more clue - if i name the empty path (eg path: 'main') then the guard works correctly and runs only when the 'main' path is activated. So the issue is: |
We have the exact same issue as described by @akturatech. Any updates regarding this? |
@AlexanderOpran No. This issue seems to haven fallen through the cracks. @indraraj26 Do you know how I can raise this with the angular team as we've had no response yet. Should I re-raise the issue again? |
@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. |
Likely caused by d7dd295 which should be reverted. |
Note that as a temporary workaround, you can use
because the PR was meant to respect the ordering with prioritization, but only works with returning |
@atscott Thank you for the update and workaround :) |
…f needed There is a slight difference between `map`...`concatAll` and `concatMap` in that the latter (`concatMap`) will ensure that the computations are executed in-order and only if needed while the former may execute the `map` body of all items if they do not emit immediately. That is, if the stream is `from([a, b, c]).pipe(map(v => of(v).pipe(delay(1))), concatAll(), first())` the `map` body will execute for all of `a`, `b`, and `c`. However, the following will only execute the `concatMap` body for `a` `from([a, b, c]).pipe(concatMap(v => of(v).pipe(delay(1))), first())` See https://stackblitz.com/edit/rxjs-cvwxyx fixes angular#38691
@akturatech I have a fix for this out for review and it should make it into the |
I have the same issue, thank you for the workaround! Edit: |
…f needed (#38780) There is a slight difference between `map`...`concatAll` and `concatMap` in that the latter (`concatMap`) will ensure that the computations are executed in-order and only if needed while the former may execute the `map` body of all items if they do not emit immediately. That is, if the stream is `from([a, b, c]).pipe(map(v => of(v).pipe(delay(1))), concatAll(), first())` the `map` body will execute for all of `a`, `b`, and `c`. However, the following will only execute the `concatMap` body for `a` `from([a, b, c]).pipe(concatMap(v => of(v).pipe(delay(1))), first())` See https://stackblitz.com/edit/rxjs-cvwxyx fixes #38691 PR Close #38780
Fixed in 9c51ba3 |
That is awesome @atscott . Thank you so much. |
@atscott Thank you for the workaround suggestion. I finally got to test it. Unfortunately setting UrlTree doesn't work for us as the guard redirects to a different subdomain on authentication failure (or app has a subdomain per user and a root subdomain for login) and therefore we cannot use UrlTree. |
Issue still persists even with |
Hi @AlexanderOpran, could you provide a reproduction? The stackblitz for this report does work with 10.1.2: https://stackblitz.com/edit/angular-ivy-sez7kw?file=src%2Fapp%2Fapp.component.ts |
Good morning @atscott. I can confirm my project now works perfectly with 10.1.2. Thank you!! |
@atscott I will try and do a stackblitz to reproduce this. Perhaps another related issue but router.navigate does not seem to work from inside guards. It will trigger the module guard infinitely even if the page/module I try to navigate to is not protected by any. This is also happening only with the ** path, not the named ones. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
🐞 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.
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:
The text was updated successfully, but these errors were encountered: