Parent guard function is calling while a child guard function is pending result
See original GitHub issueBug Report
Packages
“@angular/common”: “~9.1.12”, “@angular/compiler”: “~9.1.12”, “@angular/core”: “~9.1.12”, …
Description
I have next routes:
/nodes
/items
/items/subitems/:sid
Every route is routing module.
I have guards “canDeactivate” for items
module and for /items/subitems/:sid
module.
When I navigate in browser from /items/subitems/:sid
to /nodes
, Angular calls guards “canDeactivate”. The guard for /items/subitems/:sid
returns Promise<boolean>
result, so it’s asynchronous result and it’s pending, but after this guard, Angular calls /items
guard.
Parent route (for /items
) doesn’t have result from child guard (for /items/subitems/:sid
), because it’s pending, but Angular calls it. It looks like a bug.
Should Angular call guard for /items
while /items/subitems/:sid
is pending?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How can I use the type guard of the parent interface in ...
Simplest solution : Just swap it around: function isExtendsBase(value: any): value is ExtendsBase { return 'bar' in value && typeof ...
Read more >Router Guards • Angular - codecraft.tv
We setup our guard function to accept the guard function parameters, the component, future activated route and future router state. · If component.canDeactivate ......
Read more >FAMILY CODE CHAPTER 153. CONSERVATORSHIP, ...
(1) there is a history or pattern of committing family violence during the two ... (a) If a party to a pending suit...
Read more >clone(2) - Linux manual page
When the fn(arg) function returns, the child process terminates. ... As with fork(2), clone3() returns in both the parent and the child.
Read more >Invoking Services | XState Docs
data - (optional, used only when invoking machines) an object that maps properties of the child machine's context to a function that returns ......
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
Again Angular team is shuting down issue without reasoning why It is working this way and picking up discussion, even though we now have 20 upvotes rule - here the issue was up for one day? How could people even read issues before You take them down this way?
second thing it’s not a duplicate either as in mentioned issue there are multiple async guards in one node of routing and workaround is to use some hacky way with external que service or to separate those guards into separate empty string path nodes of routing and then It works fine. Here we already have multiple nodes so why CanDeactivate is working differently than all other guards and resolvers? And if there is a good reason mayby it’s not mentioned clearly in documentation, Also why not add option to change this behavior to match other guards?
Also new router mentioned would be great but looking at how typed forms are going we will wiat another 5 years minimum for it.
Please stop closing issues just beacause - this is so annoying.
This is working as intended. Please refer to https://github.com/angular/angular/issues/40577 and specifically https://github.com/angular/angular/issues/40577#issuecomment-768209703 if you have guards which are order-dependent.