Router Guards inconsistency
See original GitHub issue🐞 bug report
Affected Package
The issue is caused by package @angular/router
Description
CanActivate, CanActivateChild and CanDeactivate wait for the first value emitted from the returned observable, while CanLoad waits for the observable to complete.
I find inconsistent how router guards behave, as it was stated in #25262.
It was stated that this behavior is documented, but it’s not. The documentation says that
The Router guards require an observable to complete
, but it’s not true. CanActivate and other guards don’t require it.
Even if it was well documented, I think this behavior should be standardized. What do you think? 😃
🔬 Minimal Reproduction
https://stackblitz.com/edit/angular-canload-test
🌍 Your Environment
Angular Version:
Angular CLI: 7.1.1
Node: 8.11.1
OS: darwin x64
Angular: 7.1.1
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, http, language-service, material, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.11.1
@angular-devkit/build-angular 0.11.1
@angular-devkit/build-optimizer 0.11.1
@angular-devkit/build-webpack 0.11.1
@angular-devkit/core 7.1.1
@angular-devkit/schematics 7.1.1
@angular/pwa 0.11.1
@ngtools/webpack 7.1.1
@schematics/angular 7.1.1
@schematics/update 0.11.1
rxjs 6.3.3
typescript 3.1.6
webpack 4.23.1
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Troubleshooting Spanning Tree PVID- and Type-Inconsistencies
Loop inconsistency—This is detected by the Loop Guard feature. For more information, refer to Spanning-Tree Protocol Enhancements using Loop ...
Read more >Angular router activates wrong route guard - Stack Overflow
Navigating directly to a route like /activate , for example, causes a discrepancy between router state and angular router state, ...
Read more >canLoad guard does not subscribe to Observable<boolean>
The Router guards require an Observable to complete , meaning it has emitted ... So there is a real inconsistency about guards behavior...
Read more >Configuring Root Guard & Loop Guard - mrn-cciew
If a loop guard enabled root or blocked port stop a receiving BPDUs from its designated port, it transitions to the loop-inconsistent blocking ......
Read more >BPDU Protection for Spanning-Tree Protocols | Junos OS
MX Series routers, ACX Series routers, and EX Series switches support ... the interface transitioned to a BPDU inconsistent state, shutting down the ......
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 Free
Top 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
It looks like we need to look at changing this feature in the long-term, but in the short term we should update the docs to be more accurate.
Closing as obsolete. Updating the above example shows that the guards do not need to complete and that they all work the same. https://github.com/angular/angular/blob/cb48bde35d24f78f93e38fe487a0c42fee234ce6/packages/router/src/operators/check_guards.ts#L124